]> granicus.if.org Git - file/commitdiff
Fix printf formats (use alternate form for %x).
authorChristos Zoulas <christos@zoulas.com>
Wed, 29 Mar 2017 15:57:48 +0000 (15:57 +0000)
committerChristos Zoulas <christos@zoulas.com>
Wed, 29 Mar 2017 15:57:48 +0000 (15:57 +0000)
src/cdf.c
src/cdf_time.c
src/compress.c
src/readelf.c
src/softmagic.c

index 22a96eda469fa847cacaccda2954e54447072417..fdf698c5a88b5a888a5dcebba092cbeceb019f67 100644 (file)
--- a/src/cdf.c
+++ b/src/cdf.c
@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.95 2017/03/28 15:13:07 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.96 2017/03/29 15:57:48 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -340,18 +340,18 @@ cdf_read_header(const cdf_info_t *info, cdf_header_t *h)
        cdf_unpack_header(h, buf);
        cdf_swap_header(h);
        if (h->h_magic != CDF_MAGIC) {
-               DPRINTF(("Bad magic 0x%" INT64_T_FORMAT "x != 0x%"
+               DPRINTF(("Bad magic %#" INT64_T_FORMAT "x != %#"
                    INT64_T_FORMAT "x\n",
                    (unsigned long long)h->h_magic,
                    (unsigned long long)CDF_MAGIC));
                goto out;
        }
        if (h->h_sec_size_p2 > 20) {
-               DPRINTF(("Bad sector size 0x%u\n", h->h_sec_size_p2));
+               DPRINTF(("Bad sector size %#hu\n", h->h_sec_size_p2));
                goto out;
        }
        if (h->h_short_sec_size_p2 > 20) {
-               DPRINTF(("Bad short sector size 0x%u\n",
+               DPRINTF(("Bad short sector size %#hu\n",
                    h->h_short_sec_size_p2));
                goto out;
        }
@@ -931,7 +931,7 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
                        goto out;
                inp[i].pi_id = CDF_GETUINT32(p, i << 1);
                inp[i].pi_type = CDF_GETUINT32(q, 0);
-               DPRINTF(("%" SIZE_T_FORMAT "u) id=%x type=%x offs=0x%tx,0x%x\n",
+               DPRINTF(("%" SIZE_T_FORMAT "u) id=%#x type=%#x offs=%#tx,%#x\n",
                    i, inp[i].pi_id, inp[i].pi_type, q - p, offs));
                if (inp[i].pi_type & CDF_VECTOR) {
                        nelements = CDF_GETUINT32(q, 1);
@@ -1050,7 +1050,7 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
                        break;
                default:
                unknown:
-                       DPRINTF(("Don't know how to deal with %x\n",
+                       DPRINTF(("Don't know how to deal with %#x\n",
                            inp[i].pi_type));
                        break;
                }
@@ -1215,7 +1215,7 @@ cdf_print_property_name(char *buf, size_t bufsiz, uint32_t p)
        for (i = 0; i < __arraycount(vn); i++)
                if (vn[i].v == p)
                        return snprintf(buf, bufsiz, "%s", vn[i].n);
-       return snprintf(buf, bufsiz, "0x%x", p);
+       return snprintf(buf, bufsiz, "%#x", p);
 }
 
 int
@@ -1274,7 +1274,7 @@ cdf_dump_header(const cdf_header_t *h)
     h->h_ ## b, 1 << h->h_ ## b)
        DUMP("%d", revision);
        DUMP("%d", version);
-       DUMP("0x%x", byte_order);
+       DUMP("%#x", byte_order);
        DUMP2("%d", sec_size_p2);
        DUMP2("%d", short_sec_size_p2);
        DUMP("%d", num_sectors_in_sat);
@@ -1368,7 +1368,7 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
                    d->d_color ? "black" : "red");
                (void)fprintf(stderr, "Left child: %d\n", d->d_left_child);
                (void)fprintf(stderr, "Right child: %d\n", d->d_right_child);
-               (void)fprintf(stderr, "Flags: 0x%x\n", d->d_flags);
+               (void)fprintf(stderr, "Flags: %#x\n", d->d_flags);
                cdf_timestamp_to_timespec(&ts, d->d_created);
                (void)fprintf(stderr, "Created %s", cdf_ctime(&ts.tv_sec, buf));
                cdf_timestamp_to_timespec(&ts, d->d_modified);
@@ -1461,7 +1461,7 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
                        (void)fprintf(stderr, "CLIPBOARD %u\n", info[i].pi_u32);
                        break;
                default:
-                       DPRINTF(("Don't know how to deal with %x\n",
+                       DPRINTF(("Don't know how to deal with %#x\n",
                            info[i].pi_type));
                        break;
                }
@@ -1480,7 +1480,7 @@ cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst)
        (void)&h;
        if (cdf_unpack_summary_info(sst, h, &ssi, &info, &count) == -1)
                return;
-       (void)fprintf(stderr, "Endian: %x\n", ssi.si_byte_order);
+       (void)fprintf(stderr, "Endian: %#x\n", ssi.si_byte_order);
        (void)fprintf(stderr, "Os Version %d.%d\n", ssi.si_os_version & 0xff,
            ssi.si_os_version >> 8);
        (void)fprintf(stderr, "Os %d\n", ssi.si_os);
index 67296acdc3de8ebebe62f3337fa67cffd37892d3..2bdcd2a7f7a8a9bbe51a3a10f69ac1020387b38d 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf_time.c,v 1.14 2014/04/17 12:44:01 christos Exp $")
+FILE_RCSID("@(#)$File: cdf_time.c,v 1.16 2017/03/29 15:57:48 christos Exp $")
 #endif
 
 #include <time.h>
@@ -171,7 +171,7 @@ cdf_ctime(const time_t *sec, char *buf)
        char *ptr = ctime_r(sec, buf);
        if (ptr != NULL)
                return buf;
-       (void)snprintf(buf, 26, "*Bad* 0x%16.16" INT64_T_FORMAT "x\n",
+       (void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n",
            (long long)*sec);
        return buf;
 }
index 0a2dd3486b980ea88cd93836a93e23f204d14e86..3dfb980de3b1207efdebe9c4398c9b6ff18bfe4c 100644 (file)
@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.102 2017/02/10 18:14:01 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.104 2017/03/29 15:57:48 christos Exp $")
 #endif
 
 #include "magic.h"
@@ -749,9 +749,9 @@ err:
                rv = makeerror(newch, n, "Wait failed, %s", strerror(errno));
                DPRINTF("Child wait return %#x\n", status);
        } else if (!WIFEXITED(status)) {
-               DPRINTF("Child not exited (0x%x)\n", status);
+               DPRINTF("Child not exited (%#x)\n", status);
        } else if (WEXITSTATUS(status) != 0) {
-               DPRINTF("Child exited (0x%d)\n", WEXITSTATUS(status));
+               DPRINTF("Child exited (%#u)\n", WEXITSTATUS(status));
        }
 
        closefd(fdp[STDIN_FILENO], 0);
index 3695c890bb38eef45e91f79cd68d5c2cce26cbf2..a1cb21610f046e59e03afadcf2e967a42471cd90 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.132 2017/02/11 18:12:03 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.134 2017/03/29 15:57:48 christos Exp $")
 #endif
 
 #ifdef BUILTIN_ELF
@@ -1031,13 +1031,13 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
        }
 
        if (namesz & 0x80000000) {
-           (void)file_printf(ms, ", bad note name size 0x%lx",
+           (void)file_printf(ms, ", bad note name size %#lx",
                (unsigned long)namesz);
            return 0;
        }
 
        if (descsz & 0x80000000) {
-           (void)file_printf(ms, ", bad note description size 0x%lx",
+           (void)file_printf(ms, ", bad note description size %#lx",
                (unsigned long)descsz);
            return 0;
        }
@@ -1250,9 +1250,9 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
                        if ((uintmax_t)(xsh_size + xsh_offset) >
                            (uintmax_t)fsize) {
                                if (file_printf(ms,
-                                   ", note offset/size 0x%" INTMAX_T_FORMAT
-                                   "x+0x%" INTMAX_T_FORMAT "x exceeds"
-                                   " file size 0x%" INTMAX_T_FORMAT "x",
+                                   ", note offset/size %#" INTMAX_T_FORMAT
+                                   "x+%#" INTMAX_T_FORMAT "x exceeds"
+                                   " file size %#" INTMAX_T_FORMAT "x",
                                    (uintmax_t)xsh_offset, (uintmax_t)xsh_size,
                                    (uintmax_t)fsize) == -1)
                                        return -1;
@@ -1356,7 +1356,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
                                default:
                                        if (file_printf(ms,
                                            ", with unknown capability "
-                                           "0x%" INT64_T_FORMAT "x = 0x%"
+                                           "%#" INT64_T_FORMAT "x = %#"
                                            INT64_T_FORMAT "x",
                                            (unsigned long long)xcap_tag,
                                            (unsigned long long)xcap_val) == -1)
@@ -1410,13 +1410,13 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
                        }
                        if (cap_hw1)
                                if (file_printf(ms,
-                                   " unknown hardware capability 0x%"
+                                   " unknown hardware capability %#"
                                    INT64_T_FORMAT "x",
                                    (unsigned long long)cap_hw1) == -1)
                                        return -1;
                } else {
                        if (file_printf(ms,
-                           " hardware capability 0x%" INT64_T_FORMAT "x",
+                           " hardware capability %#" INT64_T_FORMAT "x",
                            (unsigned long long)cap_hw1) == -1)
                                return -1;
                }
@@ -1432,7 +1432,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
                cap_sf1 &= ~SF1_SUNW_MASK;
                if (cap_sf1)
                        if (file_printf(ms,
-                           ", with unknown software capability 0x%"
+                           ", with unknown software capability %#"
                            INT64_T_FORMAT "x",
                            (unsigned long long)cap_sf1) == -1)
                                return -1;
@@ -1486,7 +1486,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
                        if (((align = xph_align) & 0x80000000UL) != 0 ||
                            align < 4) {
                                if (file_printf(ms, 
-                                   ", invalid note alignment 0x%lx",
+                                   ", invalid note alignment %#lx",
                                    (unsigned long)align) == -1)
                                        return -1;
                                align = 4;
index b60e0bdf591d158fab73788cad47df79339865b6..39a2cb5a0840e7a31a9afe07832b936ccd330060 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.246 2017/03/08 20:45:35 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.247 2017/03/29 15:57:48 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -1365,7 +1365,7 @@ mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
                return -1;
 
        if ((ms->flags & MAGIC_DEBUG) != 0) {
-               fprintf(stderr, "mget(type=%d, flag=%x, offset=%u, o=%"
+               fprintf(stderr, "mget(type=%d, flag=%#x, offset=%u, o=%"
                    SIZE_T_FORMAT "u, " "nbytes=%" SIZE_T_FORMAT
                    "u, il=%hu, nc=%hu)\n",
                    m->type, m->flag, offset, o, nbytes,