[PATCH] D71119: [NFC][AIX][XCOFF] fixed compile warning on the strncpy.
Digger via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 6 07:24:48 PST 2019
DiggerLin created this revision.
DiggerLin added reviewers: daltenty, jasonliu, hubert.reinterpretcast, sfertile.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a reviewer: jdoerfert.
Herald added a project: LLVM.
There is warning when compile the file XCOFFObjectWriter.cpp
/srv/llvm-buildbot-srcatch/llvm-build-dir/openmp-gcc-x86_64-linux-debian/llvm.src/llvm/lib/MC/XCOFFObjectWriter.cpp:414:17: warning: 'char* strncpy(char*, const char*, size_t)' specified bound 8 equals destination size [-Wstringop-truncation]
the patch fixed the warning.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71119
Files:
llvm/lib/MC/XCOFFObjectWriter.cpp
Index: llvm/lib/MC/XCOFFObjectWriter.cpp
===================================================================
--- llvm/lib/MC/XCOFFObjectWriter.cpp
+++ llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -416,7 +416,7 @@
W.write<int32_t>(0);
W.write<uint32_t>(Strings.getOffset(SymbolName));
} else {
- char Name[XCOFF::NameSize];
+ char Name[XCOFF::NameSize+1];
std::strncpy(Name, SymbolName.data(), XCOFF::NameSize);
ArrayRef<char> NameRef(Name, XCOFF::NameSize);
W.write(NameRef);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71119.232560.patch
Type: text/x-patch
Size: 502 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191206/4d945582/attachment-0001.bin>
More information about the llvm-commits
mailing list