[llvm] c04b63e - [NFC][AIX][XCOFF] fixed compile warning on the strncpy.
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 6 09:22:56 PST 2019
Author: diggerlin
Date: 2019-12-06T12:22:28-05:00
New Revision: c04b63eccd5f9fc19da410caea88d29f11e9886c
URL: https://github.com/llvm/llvm-project/commit/c04b63eccd5f9fc19da410caea88d29f11e9886c
DIFF: https://github.com/llvm/llvm-project/commit/c04b63eccd5f9fc19da410caea88d29f11e9886c.diff
LOG: [NFC][AIX][XCOFF] fixed compile warning on the strncpy.
SUMMARY:
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.
Reviewer: daltenty
Differential Revision: https://reviews.llvm.org/D71119
Added:
Modified:
llvm/lib/MC/XCOFFObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 773ca3a0909d..788de885e416 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -416,7 +416,7 @@ void XCOFFObjectWriter::writeSymbolName(const StringRef &SymbolName) {
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);
More information about the llvm-commits
mailing list