[PATCH] D28991: [lld] Use %u instead of %d for uint32_t formatting

Hugh Bellamy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 12 22:35:25 PST 2017


hughbe updated this revision to Diff 88157.
hughbe added a comment.

Use snprintf


https://reviews.llvm.org/D28991

Files:
  COFF/Writer.cpp


Index: COFF/Writer.cpp
===================================================================
--- COFF/Writer.cpp
+++ COFF/Writer.cpp
@@ -205,7 +205,8 @@
   *Hdr = Header;
   if (StringTableOff) {
     // If name is too long, write offset into the string table as a name.
-    sprintf(Hdr->Name, "/%d", StringTableOff);
+    snprintf(Hdr->Name, static_cast<size_t>(COFF::NameSize), "/%lu",
+             static_cast<unsigned long>(StringTableOff));
   } else {
     assert(!Config->Debug || Name.size() <= COFF::NameSize);
     strncpy(Hdr->Name, Name.data(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28991.88157.patch
Type: text/x-patch
Size: 557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170213/06af5bbd/attachment.bin>


More information about the llvm-commits mailing list