Bladeren bron

dpkg-split: Use a constant expression to declare an array

Although usually the compiler should replace strlen(literal) with a
built-in, it might not, and it's more predictable to use a constant
expression using sizeof() instead to avoid making it a variable
length array. This fixes a warning with latest gcc and -Wvla.
Guillem Jover 15 jaren geleden
bovenliggende
commit
df6a6091b3
1 gewijzigde bestanden met toevoegingen van 1 en 1 verwijderingen
  1. 1 1
      dpkg-split/info.c

+ 1 - 1
dpkg-split/info.c

@@ -75,7 +75,7 @@ struct partinfo *read_info(FILE *partfile, const char *fn, struct partinfo *ir)
 
 
   size_t thisilen;
   size_t thisilen;
   unsigned int templong;
   unsigned int templong;
-  char magicbuf[strlen(DPKG_AR_MAGIC)], *rip, *partnums, *slash;
+  char magicbuf[sizeof(DPKG_AR_MAGIC) - 1], *rip, *partnums, *slash;
   struct ar_hdr arh;
   struct ar_hdr arh;
   int c;
   int c;
   struct stat stab;
   struct stat stab;