]> granicus.if.org Git - zziplib/commitdiff
zzip: info: avoid warning due to comparison with different signedness
authorPatrick Steinhardt <ps@pks.im>
Tue, 21 May 2019 11:39:50 +0000 (13:39 +0200)
committerPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2019 06:33:34 +0000 (08:33 +0200)
In `zzip_compr_str` we compare the integer value `compr` with
`LENGTH(comprlevel)`, which returns an unsigned value, causing the
compiler to emit a warning. As we're already verifying that `compr` is a
positive value, we can just cast it to an unsigned integer to avoid that
warning.

zzip/info.c

index 2482576277590da0eaae1dd5ad0c24a40aa1ba6b..4b7e941b8e7aba71321ba7e5f220fdddab247e47 100644 (file)
@@ -70,7 +70,7 @@ static const char* comprlevel[] = {
 zzip_char_t *
 zzip_compr_str(int compr)
 {
-    if (0 <= compr && compr < LENGTH(comprlevel))
+    if (0 <= compr && (unsigned) compr < LENGTH(comprlevel))
     {
         return comprlevel[compr];
     } else if (0 < compr && compr < 256)