When building with gcc TSan on, and in Debug mode, we see a warning
like:
benchmark/src/timers.cc: In function ‘std::string benchmark::LocalDateTimeString()’:
src/timers.cc:241:15: warning: ‘char* strncat(char*, const char*, size_t)’ output may be truncated copying 108 bytes from a string of length 127 [-Wstringop-truncation]
241 | std::strncat(storage, tz_offset, sizeof(storage) - timestamp_len - 1);
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
While this is essentially a false positive (we never expect
the number of bytes in tz_offset to be too large), the compiler can't
actually tell that. Shrink the size of tz_offset to a smaller, but still safe
size to eliminate this warning.
Signed-off-by:
Chris Lalancette <clalancette@openrobotics.org>
| Name |
Last commit
|
Last update |
|---|---|---|
| .github | Loading commit data... | |
| bindings/python | Loading commit data... | |
| cmake | Loading commit data... | |
| docs | Loading commit data... | |
| include/benchmark | Loading commit data... | |
| src | Loading commit data... | |
| test | Loading commit data... | |
| tools | Loading commit data... | |
| .clang-format | Loading commit data... | |
| .gitignore | Loading commit data... | |
| .travis-libcxx-setup.sh | Loading commit data... | |
| .travis.yml | Loading commit data... | |
| .ycm_extra_conf.py | Loading commit data... | |
| AUTHORS | Loading commit data... | |
| BUILD.bazel | Loading commit data... | |
| CMakeLists.txt | Loading commit data... | |
| CONTRIBUTING.md | Loading commit data... | |
| CONTRIBUTORS | Loading commit data... | |
| LICENSE | Loading commit data... | |
| README.md | Loading commit data... | |
| WORKSPACE | Loading commit data... | |
| _config.yml | Loading commit data... | |
| appveyor.yml | Loading commit data... | |
| dependencies.md | Loading commit data... | |
| requirements.txt | Loading commit data... | |
| setup.py | Loading commit data... |