[Webkit-unassigned] [Bug 174506] New: Silence -Wformat-truncation warning in ConfigFile.cpp
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Jul 14 09:26:20 PDT 2017
https://bugs.webkit.org/show_bug.cgi?id=174506
Bug ID: 174506
Summary: Silence -Wformat-truncation warning in ConfigFile.cpp
Product: WebKit
Version: Other
Hardware: PC
OS: Linux
Status: NEW
Severity: Minor
Priority: P2
Component: JavaScriptCore
Assignee: webkit-unassigned at lists.webkit.org
Reporter: mcatanzaro at igalia.com
Blocks: 174463
This is another new GCC 7 warning.
[978/5861] Building CXX object Source/...criptCore.dir/runtime/ConfigFile.cpp.o
../../Source/JavaScriptCore/runtime/ConfigFile.cpp: In lambda function:
../../Source/JavaScriptCore/runtime/ConfigFile.cpp:281:62: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
auto parseLogFile = [&](StatementNesting statementNesting) {
^
../../Source/JavaScriptCore/runtime/ConfigFile.cpp:286:29: note: ‘snprintf’ output 2 or more bytes (assuming 4098) into a destination of size 4097
snprintf(logPathname, s_maxPathLength + 1, "%s/%s", m_configDirectory, filename);
~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^
The warning means that m_configDirectory could potentially consume as much as s_maxPathLength, followed by the trailing NULL, and then the / and the filename might not get printed. That seems like the most reasonable thing to do in this case, so I think that's fine and the warning should be suppressed. Unfortunately, compilers warn when they see unknown warning suppression pragmas, so the pattern for this is not pretty. I would almost prefer to use WTF::String instead, except all the rest of the code in this function uses cstring functions.
Referenced Bugs:
https://bugs.webkit.org/show_bug.cgi?id=174463
[Bug 174463] Fix compiler warnings when building with GCC 7
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170714/494fd82f/attachment.html>
More information about the webkit-unassigned
mailing list