Skip to contentSkip to conversation

baum: Fix build with debugging enabled

PATCH Applied Samuel Thibault 3 participants 7 messages Aug 30, 2015 – Sep 6, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 baum: Fix build with debugging enabled

cur and buf are pointers, so the difference can be a long int on 64bit platforms.

backends/baum.c +1 -1
index a69aaff..0fa8025 100644
@@ -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 {\
#1 lore raw

Am 30.08.2015 um 16:19 schrieb Samuel Thibault:

Quoted 10 lines

cur and buf are pointers, so the difference can be a long int on 64bit platforms.

backends/baum.c +0 -0
index a69aaff..0fa8025 100644

backends/baum.c static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) · line 306

Quoted 5 lines
backends/baum.c +1 -1
@@ -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

#2 lore raw
Quoted 6 lines · Stefan Weil, le Sun 30 Aug 2015 16:38:25 +0200, a écrit :

Am 30.08.2015 um 16:19 schrieb Samuel Thibault:

Quoted 5 lines

cur and buf are pointers, so the difference can be a long int on 64bit platforms.

Quoted 12 lines

backends/baum.c static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) · line 306

Quoted 10 lines
backends/baum.c +1 -1
index a69aaff..0fa8025 100644
@@ -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

#3 lore raw

Am 30.08.2015 um 16:50 schrieb Samuel Thibault:

Quoted 20 lines
Quoted 6 lines · Stefan Weil, le Sun 30 Aug 2015 16:38:25 +0200, a écrit :

Am 30.08.2015 um 16:19 schrieb Samuel Thibault:

Quoted 5 lines

cur and buf are pointers, so the difference can be a long int on 64bit platforms.

Quoted 12 lines

backends/baum.c static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) · line 306

Quoted 10 lines
backends/baum.c +1 -1
index a69aaff..0fa8025 100644
@@ -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.

Quoted 4 lines

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

#4 lore raw
In reply to Samuel Thibault

cur and buf are pointers, so the difference is a ptrdiff_t

backends/baum.c +1 -1
index a69aaff..1f9288e 100644
@@ -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 %td bytes!\n", cur - buf);
     }
 
 #define EAT(c) do {\
Reviewed-by
#5 lore raw

Am 30.08.2015 um 17:12 schrieb Samuel Thibault:

Quoted 10 lines

cur and buf are pointers, so the difference is a ptrdiff_t

backends/baum.c +0 -0
index a69aaff..1f9288e 100644

backends/baum.c static int baum_eat_packet(BaumDriverState *baum, const uint8_t *buf, int len) · line 309

Quoted 8 lines
backends/baum.c +1 -1
@@ -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 %td bytes!\n", cur - buf);
     }
 
 #define EAT(c) do {\

Please don't send patches as reply to previous e-mails and use a subject which shows the patch revision (here "[PATCH v2] baum: Fix build with debugging enabled") for future patches.