[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 19:27:07 PST 2021
nullptr.cpp updated this revision to Diff 317452.
nullptr.cpp added a comment.
Use StringRef
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
@@ -138,12 +138,13 @@
Group->clear();
}
- Section(const char *N, XCOFF::SectionTypeFlags Flags, bool IsVirtual,
+ Section(StringRef 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(N.size() <= XCOFF::NameSize && "section name too long");
+ memcpy(Name, N.data(), N.size());
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94872.317452.patch
Type: text/x-patch
Size: 973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210119/b9addc14/attachment.bin>
More information about the llvm-commits
mailing list