[PATCH] D94872: [NFC][AIX][XCOFF] Fix compile warning on strncpy
Hubert Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 18 17:21:29 PST 2021
hubert.reinterpretcast added inline comments.
================
Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:146
+ Index(UninitializedIndex), IsVirtual(IsVirtual), Groups(Groups) {
+ assert(strlen(N) <= XCOFF::NameSize && "section name too long");
+ memcpy(Name, N, strlen(N));
----------------
I think `N` did not need to be a null-terminated string (if 8 characters long) before the change. Would be make sense to change `N` to be a `StringRef` and use the length from that? I think that makes it clear that just passing the argument either requires an explicit length or a terminating NUL.
Thanks for adding a check here to catch improper usage.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94872/new/
https://reviews.llvm.org/D94872
More information about the llvm-commits
mailing list