[all-commits] [llvm/llvm-project] e4a672: [lld][macho] Fix gcc category merging warning (#86...

alx32 via All-commits all-commits at lists.llvm.org
Thu Mar 21 14:53:30 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e4a672ef85f76c3402b81640e1e83e5d3069d1b9
      https://github.com/llvm/llvm-project/commit/e4a672ef85f76c3402b81640e1e83e5d3069d1b9
  Author: alx32 <103613512+alx32 at users.noreply.github.com>
  Date:   2024-03-21 (Thu, 21 Mar 2024)

  Changed paths:
    M lld/MachO/ObjC.cpp

  Log Message:
  -----------
  [lld][macho] Fix gcc category merging warning (#86091)

Fixing gcc warning regarding creating non-null-terminated string:
```
../../lld/MachO/ObjC.cpp:1226:10: warning: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
 1226 |   strncpy(strData, str, len);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~
../../lld/MachO/ObjC.cpp: In member function 'void {anonymous}::ObjcCategoryMerger::emitAndLinkPointerList(lld::macho::Defined*, uint32_t, const {anonymous}::ObjcCategoryMerger::ClassExtensionInfo&, const {anonymous}::ObjcCategoryMerger::PointerListInfo&)':
../../lld/MachO/ObjC.cpp:1223:24: note: length computed here
 1223 |   uint32_t len = strlen(str);
      |                  ~~~~~~^~~~~
```
This is not actually a bug, as `newSectionData` returns a
zero-initialized memory region, so the null terminator will be there.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list