Skip to contentSkip to conversation

batctl: tcpdump: Fix printing of usecs

PATCH New Sven Eckelmann 1 participant 1 message Mar 8

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batctl: tcpdump: Fix printing of usecs

musl on a 32 bit system still uses a 64-bit value (long long) for the storage of microseconds. But the printf was evaluating this argument always only as long.

During the print of this usec value, range of 0-999_999 is only possible. 20 bit is therefore enough to store this range. For simplicity, just use an unsigned int.

---
 tcpdump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tcpdump.c +2 -1
index 32f9a04..c89b5a7 100644
@@ -102,7 +102,8 @@ static int print_time(void)
 	tm = localtime(&tv.tv_sec);
 
 	if (tm)
-		printf("%02d:%02d:%02d.%06ld ", tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec);
+		printf("%02d:%02d:%02d.%06u ", tm->tm_hour, tm->tm_min, tm->tm_sec,
+		       (unsigned int)tv.tv_usec);
 	else
 		printf("00:00:00.000000 ");
 

---
base-commit: 8d256ac07c7dada8607ae792dcd0524d91eef127
change-id: 20260308-t64-95a132121e4f

Best regards,

Signature · 1 line
Sven Eckelmann <[email protected]>