Message ID | 20150830141909.GA13186@var.home |
---|---|
State | New |
Headers | show |
Am 30.08.2015 um 16:19 schrieb Samuel Thibault: > cur and buf are pointers, so the difference can be a long int on 64bit > platforms. > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> > > diff --git a/backends/baum.c b/backends/baum.c > index a69aaff..0fa8025 100644 > --- a/backends/baum.c > +++ b/backends/baum.c > @@ -303,7 +303,7 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) > return 0; > cur++; > } > - DPRINTF("Dropped %d bytes!\n", cur - buf); > + DPRINTF("Dropped %ld bytes!\n", (long int) (cur - buf)); Using %td (and no type cast) would be better. Regards Stefan
Stefan Weil, le Sun 30 Aug 2015 16:38:25 +0200, a écrit : > Am 30.08.2015 um 16:19 schrieb Samuel Thibault: > > cur and buf are pointers, so the difference can be a long int on 64bit > > platforms. > > > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> > > > > diff --git a/backends/baum.c b/backends/baum.c > > index a69aaff..0fa8025 100644 > > --- a/backends/baum.c > > +++ b/backends/baum.c > > @@ -303,7 +303,7 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) > > return 0; > > cur++; > > } > > - DPRINTF("Dropped %d bytes!\n", cur - buf); > > + DPRINTF("Dropped %ld bytes!\n", (long int) (cur - buf)); > > Using %td (and no type cast) would be better. Ah, do we assume that %td is supported by libc? Samuel
Am 30.08.2015 um 16:50 schrieb Samuel Thibault: > Stefan Weil, le Sun 30 Aug 2015 16:38:25 +0200, a écrit : >> Am 30.08.2015 um 16:19 schrieb Samuel Thibault: >>> cur and buf are pointers, so the difference can be a long int on 64bit >>> platforms. >>> >>> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> >>> >>> diff --git a/backends/baum.c b/backends/baum.c >>> index a69aaff..0fa8025 100644 >>> --- a/backends/baum.c >>> +++ b/backends/baum.c >>> @@ -303,7 +303,7 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) >>> return 0; >>> cur++; >>> } >>> - DPRINTF("Dropped %d bytes!\n", cur - buf); >>> + DPRINTF("Dropped %ld bytes!\n", (long int) (cur - buf)); >> >> Using %td (and no type cast) would be better. > > Ah, do we assume that %td is supported by libc? > > Samuel > Yes. It is already used in hw/audio/es1370.c and in translate-all.c. Stefan
diff --git a/backends/baum.c b/backends/baum.c index a69aaff..0fa8025 100644 --- a/backends/baum.c +++ b/backends/baum.c @@ -303,7 +303,7 @@ static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) return 0; cur++; } - DPRINTF("Dropped %d bytes!\n", cur - buf); + DPRINTF("Dropped %ld bytes!\n", (long int) (cur - buf)); } #define EAT(c) do {\
cur and buf are pointers, so the difference can be a long int on 64bit platforms. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>