Просмотр исходного кода

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
Родитель
Сommit
df6a6091b3
1 измененных файлов с 1 добавлено и 1 удалено
  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;
   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;
   int c;
   struct stat stab;