MT#62181 silence compiler warning

src/XmlRpcValue.cpp: In member function ‘std::ostream& XmlRpc::XmlRpcValue::write(std::ostream&) const’:
src/XmlRpcValue.cpp:483:44: warning: ‘%02d’ directive output may be truncated writing between 2 and 11 bytes into a region of size between 8 and 15 [-Wformat-truncation=]
  483 |           snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
      |                                            ^~~~
src/XmlRpcValue.cpp:483:40: note: directive argument in the range [-2147483647, 2147483647]
  483 |           snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/XmlRpcValue.cpp:483:19: note: ‘snprintf’ output between 18 and 70 bytes into a destination of size 19
  483 |           snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
      |           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  484 |             (1900 + t.tm_year), (1 + t.tm_mon), t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: I38edb330bc0d0ea17fc215f745fc51e66d56d41f
mr26.0
Richard Fuchs 7 months ago
parent 2cd6f20009
commit d684e8ca9d

@ -479,7 +479,7 @@ namespace XmlRpc {
case TypeDateTime:
{
const tm& t = std::get<tm>(_value);
char buf[20];
char buf[64];
snprintf(buf, sizeof(buf)-1, "%4d%02d%02dT%02d:%02d:%02d",
(1900 + t.tm_year), (1 + t.tm_mon), t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
buf[sizeof(buf)-1] = 0;

Loading…
Cancel
Save