Azure / azure-storage-cpp

Microsoft Azure Storage Client Library for C++
http://azure.github.io/azure-storage-cpp
Apache License 2.0
132 stars 147 forks source link

Avoid warning generated by [-Wformat-truncation=] #315

Closed ghalliday closed 4 years ago

ghalliday commented 4 years ago

Signed-off-by: Gavin Halliday gavin.halliday@lexisnexis.com

ghalliday commented 4 years ago

gcc 9 generates the following without this change:

.../azure-storage-cpp/Microsoft.WindowsAzure.Storage/src/util.cpp: In function ‘utility::string_t azure::storage::core::convert_to_string_with_fixed_length_fractional_seconds(utility::datetime)’:
.../azure-storage-cpp/Microsoft.WindowsAzure.Storage/src/util.cpp:399:49: warning: ‘%s’ directive output may be truncated writing up to 8 bytes into a region of size between 1 and 65 [-Wformat-truncation=]
  399 |             snprintf(output, sizeof(output), "%s%sZ", datetime_str, buf);
      |                                                 ^~                  ~~~
.../azure-storage-cpp/Microsoft.WindowsAzure.Storage/src/util.cpp:399:21: note: ‘snprintf’ output between 2 and 74 bytes into a destination of size 65
  399 |             snprintf(output, sizeof(output), "%s%sZ", datetime_str, buf);
Jinming-Hu commented 4 years ago

Hi @ghalliday , thanks for your contribution. I just removed this function in my working branch https://github.com/JinmingHu-MSFT/azure-storage-cpp/commit/f6d64f3c93b5913a602ebc4ad257a1f690175f6e, so it won't persist in the next release.

ghalliday commented 4 years ago

Closing since function will be going away.