summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@trombone>2022-06-27 13:16:28 -0500
committerPaul Eggert <eggert@cs.ucla.edu>2022-06-28 22:42:11 -0500
commit85e0910e6ec2b81ff4b9232015a30b369aef8c0c (patch)
tree93fbc8b057058362b08c14c1c8b2a76fc037c7cb
parent83c65d124deba617ec0f5af9f2002b289ac18ba7 (diff)
downloadgzip-85e0910e6ec2b81ff4b9232015a30b369aef8c0c.tar.gz
gzip: match printf format to arg type
This pacifies gcc -Wformat -DDEBUG. * bits.c (send_bits): * deflate.c (check_match): * inflate.c (huft_build, inflate_codes): * trees.c (send_code, gen_codes, flush_block): Use correct printf formats for signed vs unsigned integers.
-rw-r--r--bits.c2
-rw-r--r--deflate.c4
-rw-r--r--inflate.c16
-rw-r--r--trees.c6
4 files changed, 19 insertions, 9 deletions
diff --git a/bits.c b/bits.c
index 572fc7c..86599ca 100644
--- a/bits.c
+++ b/bits.c
@@ -136,7 +136,7 @@ void send_bits(value, length)
int length; /* number of bits */
{
#ifdef DEBUG
- Tracev((stderr," l %2d v %4x ", length, value));
+ Tracev ((stderr, " l %2d v %4x ", length, value + 0u));
Assert(length > 0 && length <= 15, "invalid length");
bits_sent += (off_t)length;
#endif
diff --git a/deflate.c b/deflate.c
index c37dfc7..7d19ef5 100644
--- a/deflate.c
+++ b/deflate.c
@@ -508,12 +508,12 @@ local void check_match(start, match, length)
if (memcmp((char*)window + match,
(char*)window + start, length) != 0) {
fprintf(stderr,
- " start %d, match %d, length %d\n",
+ " start %u, match %u, length %d\n",
start, match, length);
gzip_error ("invalid match");
}
if (verbose > 1) {
- fprintf(stderr,"\\[%d,%d]", start-match, length);
+ fprintf (stderr, "\\[%u,%d]", start - match, length);
do { putc(window[start++], stderr); } while (--length != 0);
}
}
diff --git a/inflate.c b/inflate.c
index f54eb65..199a935 100644
--- a/inflate.c
+++ b/inflate.c
@@ -310,8 +310,18 @@ int *m /* maximum lookup bits, returns actual */
memzero(c, sizeof(c));
p = b; i = n;
do {
- Tracecv(*p, (stderr, (n-i >= ' ' && n-i <= '~' ? "%c %d\n" : "0x%x %d\n"),
- n-i, *p));
+#ifdef DEBUG
+ if (1 < verbose && *p)
+ {
+ if (' ' <= n - i && n - i <= '~')
+ {
+ char ch = n - i;
+ fprintf (stderr, "%c %u\n", ch, *p);
+ }
+ else
+ fprintf (stderr, "0x%x %u\n", n - i, *p);
+ }
+#endif
c[*p]++; /* assume all entries <= BMAX */
p++; /* Can't combine with above line (Solaris bug) */
} while (--i);
@@ -572,7 +582,7 @@ inflate_codes(struct huft *tl, struct huft *td, int bl, int bd)
NEEDBITS(e)
d = w - t->v.n - ((unsigned)b & mask_bits[e]);
DUMPBITS(e)
- Tracevv((stderr,"\\[%d,%d]", w-d, n));
+ Tracevv ((stderr, "\\[%u,%u]", w - d, n));
/* do the copy */
do {
diff --git a/trees.c b/trees.c
index 805a3b4..b88a1b9 100644
--- a/trees.c
+++ b/trees.c
@@ -319,7 +319,7 @@ local void set_file_type (void);
#else /* DEBUG */
# define send_code(c, tree) \
- { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \
+ { if (verbose > 1) fprintf (stderr, "\ncd %3u ", (c) + 0u); \
send_bits(tree[c].Code, tree[c].Len); }
#endif
@@ -603,7 +603,7 @@ local void gen_codes (tree, max_code)
tree[n].Code = bi_reverse(next_code[len]++, len);
Tracec(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
+ n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1u));
}
}
@@ -1003,7 +1003,7 @@ int ct_tally (dist, lc)
out_length += (ulg)dyn_dtree[dcode].Freq*(5L+extra_dbits[dcode]);
}
out_length >>= 3;
- Trace((stderr,"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
+ Trace((stderr,"\nlast_lit %u, last_dist %u, in %lu, out ~%lu(%lu%%) ",
last_lit, last_dist, in_length, out_length,
100L - out_length*100L/in_length));
if (last_dist < last_lit/2 && out_length < in_length/2) return 1;