[llvm] r303483 - Fix -Wunneeded-internal-declaration by removing constant arrays only used in sizeof expressions, in favor of constants containing the size directly

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri May 19 20:32:51 PDT 2017


Author: dblaikie
Date: Fri May 19 22:32:51 2017
New Revision: 303483

URL: http://llvm.org/viewvc/llvm-project?rev=303483&view=rev
Log:
Fix -Wunneeded-internal-declaration by removing constant arrays only used in sizeof expressions, in favor of constants containing the size directly

Modified:
    llvm/trunk/lib/Object/WindowsResource.cpp

Modified: llvm/trunk/lib/Object/WindowsResource.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WindowsResource.cpp?rev=303483&r1=303482&r2=303483&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WindowsResource.cpp (original)
+++ llvm/trunk/lib/Object/WindowsResource.cpp Fri May 19 22:32:51 2017
@@ -18,11 +18,9 @@
 namespace llvm {
 namespace object {
 
-static const char ResourceMagic[] = {
-    '\0',   '\0',   '\0', '\0', '\x20', '\0',   '\0', '\0',
-    '\xff', '\xff', '\0', '\0', '\xff', '\xff', '\0', '\0'};
+static const size_t ResourceMagicSize = 16;
 
-static const char NullEntry[16] = {'\0'};
+static const size_t NullEntrySize = 16;
 
 #define RETURN_IF_ERROR(X)                                                     \
   if (auto EC = X)                                                             \
@@ -30,7 +28,7 @@ static const char NullEntry[16] = {'\0'}
 
 WindowsResource::WindowsResource(MemoryBufferRef Source)
     : Binary(Binary::ID_WinRes, Source) {
-  size_t LeadingSize = sizeof(ResourceMagic) + sizeof(NullEntry);
+  size_t LeadingSize = ResourceMagicSize + NullEntrySize;
   BBS = BinaryByteStream(Data.getBuffer().drop_front(LeadingSize),
                          support::little);
 }
@@ -39,7 +37,7 @@ WindowsResource::~WindowsResource() = de
 
 Expected<std::unique_ptr<WindowsResource>>
 WindowsResource::createWindowsResource(MemoryBufferRef Source) {
-  if (Source.getBufferSize() < sizeof(ResourceMagic) + sizeof(NullEntry))
+  if (Source.getBufferSize() < ResourceMagicSize + NullEntrySize)
     return make_error<GenericBinaryError>(
         "File too small to be a resource file",
         object_error::invalid_file_type);




More information about the llvm-commits mailing list