Martin Str|mberg
2014-Nov-22 12:39 UTC
[syslinux] Use z size specifier for printf-ing size_t variable
Hello. Use the z size specifier to printf-ing size_t variables to get rid of gcc warning format ?%08x? expects type ?unsigned int?, but argument 2 has type ?long unsigned int? -- MartinS diff --git a/com32/lib/syslinux/initramfs_file.c b/com32/lib/syslinux/initramfs_file.c index 7eb55b5..9f9fa75 100644 --- a/com32/lib/syslinux/initramfs_file.c +++ b/com32/lib/syslinux/initramfs_file.c @@ -126,7 +126,7 @@ int initramfs_mknod(struct initramfs *ihead, const char *filename, if (do_mkdir) bp += initramfs_mkdirs(filename, bp, bytes); - bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x" + bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08zx%08x%08x" "%08x%08x%08x%08x", next_ino++, mode, 0, 0, 1, 0, len, 0, 1, major, minor, namelen + 1, 0); memcpy(bp, filename, namelen); diff --git a/com32/mboot/map.c b/com32/mboot/map.c index 84f3b20..4b0baa2 100644 --- a/com32/mboot/map.c +++ b/com32/mboot/map.c @@ -61,7 +61,7 @@ addr_t map_data(const void *data, size_t len, size_t align, int flags) return 0; } - dprintf("Mapping 0x%08x bytes (%#x pad) at 0x%08x\n", len, pad, start); + dprintf("Mapping 0x%08zx bytes (%#x pad) at 0x%08x\n", len, pad, start); if (start + len + pad > mboot_high_water_mark) mboot_high_water_mark = start + len + pad; diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c index b8cb06f..ed72c08 100644 --- a/com32/menu/menumain.c +++ b/com32/menu/menumain.c @@ -230,7 +230,7 @@ static int ask_passwd(const char *menu_entry) for (x = 2; x <= WIDTH - 2 * PASSWD_MARGIN - 1; x++) putchar('q'); - printf("j\017\033[%d;%dH\2#12 %s \033[%d;%dH\2#13", + printf("j\017\033[%d;%zdH\2#12 %s \033[%d;%dH\2#13", PASSWD_ROW, (WIDTH - (strlen(cm->messages[MSG_PASSPROMPT]) + 2)) / 2, cm->messages[MSG_PASSPROMPT], PASSWD_ROW + 1, PASSWD_MARGIN + 3); diff --git a/com32/modules/cptime.c b/com32/modules/cptime.c index 0f5ffe6..315b9f9 100644 --- a/com32/modules/cptime.c +++ b/com32/modules/cptime.c @@ -216,7 +216,7 @@ int time_copy(char *fn, char do_simple, char do_verbose, size_t ibufsz, off_t ma print_cp_result_long(fn, bcnt, bc, ec, ibufsz, do_verbose); } if (do_verbose) - printf(" numrd %d bcnt %d bufsz %d i %d\n", numrd, bcnt, bufsz, i); + printf(" numrd %d bcnt %zd bufsz %zd i %d\n", numrd, bcnt, bufsz, i); } return rv; } /* int time_copy(char *fn, char do_simple, int bufsz, off_t maxlen) */ diff --git a/com32/modules/pmload.c b/com32/modules/pmload.c index 6808d38..d6239ec 100644 --- a/com32/modules/pmload.c +++ b/com32/modules/pmload.c @@ -84,10 +84,10 @@ int boot_raw(void *ptr, size_t len, addr_t where, char **argv) dprintf("Initial memory map:\n"); syslinux_dump_memmap(mmap); - dprintf("Segment at 0x%08x len 0x%08x\n", where, len); + dprintf("Segment at 0x%08x len 0x%08zx\n", where, len); if (syslinux_memmap_type(amap, where, len) != SMT_FREE) { - printf("Memory segment at 0x%08x (len 0x%08x) is unavailable\n", + printf("Memory segment at 0x%08x (len 0x%08zx) is unavailable\n", where, len); goto bail; /* Memory region unavailable */ } diff --git a/com32/sysdump/dmi.c b/com32/sysdump/dmi.c index ce25efa..7c39b7b 100644 --- a/com32/sysdump/dmi.c +++ b/com32/sysdump/dmi.c @@ -65,7 +65,7 @@ static void dump_smbios(struct upload_backend *be, size_t dptr) struct smbios_header smx = *smb; char filename[32]; - snprintf(filename, sizeof filename, "dmi/%05x.%08x", + snprintf(filename, sizeof filename, "dmi/%05zx.%08x", dptr, smb->dmi.tbladdr); cpio_hdr(be, MODE_FILE, smb->dmi.tbllen + 32, filename); @@ -90,7 +90,7 @@ static void dump_old_dmi(struct upload_backend *be, size_t dptr) } fake; char filename[32]; - snprintf(filename, sizeof filename, "dmi/%05x.%08x", + snprintf(filename, sizeof filename, "dmi/%05zx.%08x", dptr, dmi->tbladdr); cpio_hdr(be, MODE_FILE, dmi->tbllen + 32, filename);
Geert Stappers
2015-Jan-25 19:55 UTC
[syslinux] Use z size specifier for printf-ing size_t variable
On Sat, Nov 22, 2014 at 01:39:45PM +0100, Martin Str|mberg wrote:> Hello. > > Use the z size specifier to printf-ing size_t variables to get rid of gcc > warning > format ???%08x??? expects type ???unsigned int???, but argument 2 has type ???long unsigned int??? >Also in the git repo of Gene Geert Marking a Syslinux Mailing posting _with a patch_ "did got a follow-up"
Raphael S Carvalho
2015-Jan-25 20:13 UTC
[syslinux] Use z size specifier for printf-ing size_t variable
On Sat, Nov 22, 2014 at 10:39 AM, Martin Str|mberg <ams at ludd.ltu.se> wrote:> Hello. > > Use the z size specifier to printf-ing size_t variables to get rid of gcc > warning > format ?%08x? expects type ?unsigned int?, but argument 2 has type ?long unsigned int?Please, add the signed-off line.> > > -- > MartinS > > diff --git a/com32/lib/syslinux/initramfs_file.c b/com32/lib/syslinux/initramfs_file.c > index 7eb55b5..9f9fa75 100644 > --- a/com32/lib/syslinux/initramfs_file.c > +++ b/com32/lib/syslinux/initramfs_file.c > @@ -126,7 +126,7 @@ int initramfs_mknod(struct initramfs *ihead, const char *filename, > if (do_mkdir) > bp += initramfs_mkdirs(filename, bp, bytes); > > - bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08x%08x%08x" > + bp += sprintf(bp, "070701%08x%08x%08x%08x%08x%08x%08zx%08x%08x" > "%08x%08x%08x%08x", next_ino++, mode, > 0, 0, 1, 0, len, 0, 1, major, minor, namelen + 1, 0); > memcpy(bp, filename, namelen); > diff --git a/com32/mboot/map.c b/com32/mboot/map.c > index 84f3b20..4b0baa2 100644 > --- a/com32/mboot/map.c > +++ b/com32/mboot/map.c > @@ -61,7 +61,7 @@ addr_t map_data(const void *data, size_t len, size_t align, int flags) > return 0; > } > > - dprintf("Mapping 0x%08x bytes (%#x pad) at 0x%08x\n", len, pad, start); > + dprintf("Mapping 0x%08zx bytes (%#x pad) at 0x%08x\n", len, pad, start); > > if (start + len + pad > mboot_high_water_mark) > mboot_high_water_mark = start + len + pad; > diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c > index b8cb06f..ed72c08 100644 > --- a/com32/menu/menumain.c > +++ b/com32/menu/menumain.c > @@ -230,7 +230,7 @@ static int ask_passwd(const char *menu_entry) > for (x = 2; x <= WIDTH - 2 * PASSWD_MARGIN - 1; x++) > putchar('q'); > > - printf("j\017\033[%d;%dH\2#12 %s \033[%d;%dH\2#13", > + printf("j\017\033[%d;%zdH\2#12 %s \033[%d;%dH\2#13", > PASSWD_ROW, (WIDTH - (strlen(cm->messages[MSG_PASSPROMPT]) + 2)) / 2, > cm->messages[MSG_PASSPROMPT], PASSWD_ROW + 1, PASSWD_MARGIN + 3); > > diff --git a/com32/modules/cptime.c b/com32/modules/cptime.c > index 0f5ffe6..315b9f9 100644 > --- a/com32/modules/cptime.c > +++ b/com32/modules/cptime.c > @@ -216,7 +216,7 @@ int time_copy(char *fn, char do_simple, char do_verbose, size_t ibufsz, off_t ma > print_cp_result_long(fn, bcnt, bc, ec, ibufsz, do_verbose); > } > if (do_verbose) > - printf(" numrd %d bcnt %d bufsz %d i %d\n", numrd, bcnt, bufsz, i); > + printf(" numrd %d bcnt %zd bufsz %zd i %d\n", numrd, bcnt, bufsz, i); > } > return rv; > } /* int time_copy(char *fn, char do_simple, int bufsz, off_t maxlen) */ > diff --git a/com32/modules/pmload.c b/com32/modules/pmload.c > index 6808d38..d6239ec 100644 > --- a/com32/modules/pmload.c > +++ b/com32/modules/pmload.c > @@ -84,10 +84,10 @@ int boot_raw(void *ptr, size_t len, addr_t where, char **argv) > dprintf("Initial memory map:\n"); > syslinux_dump_memmap(mmap); > > - dprintf("Segment at 0x%08x len 0x%08x\n", where, len); > + dprintf("Segment at 0x%08x len 0x%08zx\n", where, len); > > if (syslinux_memmap_type(amap, where, len) != SMT_FREE) { > - printf("Memory segment at 0x%08x (len 0x%08x) is unavailable\n", > + printf("Memory segment at 0x%08x (len 0x%08zx) is unavailable\n", > where, len); > goto bail; /* Memory region unavailable */ > } > diff --git a/com32/sysdump/dmi.c b/com32/sysdump/dmi.c > index ce25efa..7c39b7b 100644 > --- a/com32/sysdump/dmi.c > +++ b/com32/sysdump/dmi.c > @@ -65,7 +65,7 @@ static void dump_smbios(struct upload_backend *be, size_t dptr) > struct smbios_header smx = *smb; > char filename[32]; > > - snprintf(filename, sizeof filename, "dmi/%05x.%08x", > + snprintf(filename, sizeof filename, "dmi/%05zx.%08x", > dptr, smb->dmi.tbladdr); > cpio_hdr(be, MODE_FILE, smb->dmi.tbllen + 32, filename); > > @@ -90,7 +90,7 @@ static void dump_old_dmi(struct upload_backend *be, size_t dptr) > } fake; > char filename[32]; > > - snprintf(filename, sizeof filename, "dmi/%05x.%08x", > + snprintf(filename, sizeof filename, "dmi/%05zx.%08x", > dptr, dmi->tbladdr); > cpio_hdr(be, MODE_FILE, dmi->tbllen + 32, filename); > > _______________________________________________ > Syslinux mailing list > Submissions to Syslinux at zytor.com > Unsubscribe or set options at: > http://www.zytor.com/mailman/listinfo/syslinux-- Raphael S. Carvalho
Martin Str|mberg
2015-Feb-06 08:55 UTC
[syslinux] Use z size specifier for printf-ing size_t variable
On Sun, Jan 25, 2015 at 06:13:13PM -0200, Raphael S Carvalho wrote:> On Sat, Nov 22, 2014 at 10:39 AM, Martin Str|mberg <ams at ludd.ltu.se> wrote: > > Hello. > > > > Use the z size specifier to printf-ing size_t variables to get rid of gcc > > warning > > format ?%08x? expects type ?unsigned int?, but argument 2 has type ?long unsigned int? > Please, add the signed-off line.I'm not sure what you want me to do. Should I resend the patch with a signed-off line? -- MartinS