[PATCH] D94872: [NFC][AIX][XCOFF] Fix compile warning on strncpy
Yang Fan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 18 01:18:00 PST 2021
nullptr.cpp updated this revision to Diff 317279.
nullptr.cpp edited the summary of this revision.
nullptr.cpp added a comment.
Use memcpy
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94872/new/
https://reviews.llvm.org/D94872
Files:
llvm/lib/MC/XCOFFObjectWriter.cpp
Index: llvm/lib/MC/XCOFFObjectWriter.cpp
===================================================================
--- llvm/lib/MC/XCOFFObjectWriter.cpp
+++ llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -140,10 +140,11 @@
Section(const char *N, XCOFF::SectionTypeFlags Flags, bool IsVirtual,
CsectGroups Groups)
- : Address(0), Size(0), FileOffsetToData(0), FileOffsetToRelocations(0),
- RelocationCount(0), Flags(Flags), Index(UninitializedIndex),
- IsVirtual(IsVirtual), Groups(Groups) {
- strncpy(Name, N, XCOFF::NameSize);
+ : Name(), Address(0), Size(0), FileOffsetToData(0),
+ FileOffsetToRelocations(0), RelocationCount(0), Flags(Flags),
+ Index(UninitializedIndex), IsVirtual(IsVirtual), Groups(Groups) {
+ assert(strlen(N) <= XCOFF::NameSize && "section name too long");
+ memcpy(Name, N, strlen(N));
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94872.317279.patch
Type: text/x-patch
Size: 869 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210118/2cf561fc/attachment.bin>
More information about the llvm-commits
mailing list