Skip to contentSkip to conversation

client/player: fix printf format string

PATCH Applied Christian Eggers 3 participants 5 messages Sep 23, 2022 – Sep 26, 2022 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 client/player: fix printf format string

Use macros from inttypes.h for correct printf format specifier for int64_t

---
 client/player.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
client/player.c +2 -2
index 0daacabf3c27..30ae263c8e41 100644
@@ -15,7 +15,7 @@
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdbool.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -3056,7 +3056,7 @@ static void send_wait(struct timespec *t_start, uint32_t us)
 	delta_us = us - TS_USEC(&t_diff);
 
 	if (delta_us < 0) {
-		bt_shell_printf("Send is behind: %zd us - skip sleep",
+		bt_shell_printf("Send is behind: %" PRId64 " us - skip sleep",
 							delta_us);
 		delta_us = 1000;
 	}
Signature · 1 line
2.35.3
#1 lore raw

PATCH 2/3 monitor: fix printf format strings

time_t is 64 bit (long long) on many 32 bit platforms (e.g. ARM) now

---
 monitor/analyze.c | 21 ++++++++++++---------
 monitor/packet.c  | 10 ++++++----
 2 files changed, 18 insertions(+), 13 deletions(-)
monitor/analyze.c +12 -9
index ac23e13bbd42..50e7e5542793 100644
@@ -172,15 +172,18 @@ static void conn_destroy(void *data)
 	print_field("%lu RX packets", conn->rx_num);
 	print_field("%lu TX packets", conn->tx_num);
 	print_field("%lu TX completed packets", conn->tx_num_comp);
-	print_field("%ld msec min latency",
-			conn->tx_lat_min.tv_sec * 1000 +
-			conn->tx_lat_min.tv_usec / 1000);
-	print_field("%ld msec max latency",
-			conn->tx_lat_max.tv_sec * 1000 +
-			conn->tx_lat_max.tv_usec / 1000);
-	print_field("%ld msec median latency",
-			conn->tx_lat_med.tv_sec * 1000 +
-			conn->tx_lat_med.tv_usec / 1000);
+	print_field("%lld msec min latency",
+			(long long)
+			(conn->tx_lat_min.tv_sec * 1000 +
+			conn->tx_lat_min.tv_usec / 1000));
+	print_field("%lld msec max latency",
+			(long long)
+			(conn->tx_lat_max.tv_sec * 1000 +
+			conn->tx_lat_max.tv_usec / 1000));
+	print_field("%lld msec median latency",
+			(long long)
+			(conn->tx_lat_med.tv_sec * 1000 +
+			conn->tx_lat_med.tv_usec / 1000));
 	print_field("%u octets TX min packet size", conn->tx_pkt_min);
 	print_field("%u octets TX max packet size", conn->tx_pkt_max);
 	print_field("%u octets TX median packet size", conn->tx_pkt_med);
monitor/packet.c +6 -4
index 1344fd5b2503..1a41498e9c52 100644
@@ -384,8 +384,9 @@ static void print_packet(struct timeval *tv, struct ucred *cred, char ident,
 		}
 
 		if (filter_mask & PACKET_FILTER_SHOW_TIME) {
-			n = sprintf(ts_str + ts_pos, " %02d:%02d:%02d.%06lu",
-				tm.tm_hour, tm.tm_min, tm.tm_sec, tv->tv_usec);
+			n = sprintf(ts_str + ts_pos, " %02d:%02d:%02d.%06llu",
+				tm.tm_hour, tm.tm_min, tm.tm_sec,
+				(long long)tv->tv_usec);
 			if (n > 0) {
 				ts_pos += n;
 				ts_len += n;
@@ -393,8 +394,9 @@ static void print_packet(struct timeval *tv, struct ucred *cred, char ident,
 		}
 
 		if (filter_mask & PACKET_FILTER_SHOW_TIME_OFFSET) {
-			n = sprintf(ts_str + ts_pos, " %lu.%06lu",
-					tv->tv_sec - time_offset, tv->tv_usec);
+			n = sprintf(ts_str + ts_pos, " %llu.%06llu",
+				(long long)(tv->tv_sec - time_offset),
+				(long long)tv->tv_usec);
 			if (n > 0) {
 				ts_pos += n;
 				ts_len += n;
Signature · 1 line
2.35.3
#2 lore raw

PATCH 3/3 tools: fix printf format strings

In reply to Christian Eggers

time_t is 64 bit (long long) on many 32 bit platforms (e.g. ARM) now

---
 tools/l2test.c | 5 +++--
 tools/rctest.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
tools/l2test.c +3 -2
index fbaca747eaaa..5aae4b687518 100644
@@ -893,8 +893,9 @@ static void recv_mode(int sk)
 					timestamp = 0;
 					memset(ts, 0, sizeof(ts));
 				} else {
-					sprintf(ts, "[%ld.%ld] ",
-							tv.tv_sec, tv.tv_usec);
+					sprintf(ts, "[%lld.%lld] ",
+							(long long)tv.tv_sec,
+							(long long)tv.tv_usec);
 				}
 			}
 
tools/rctest.c +3 -2
index 9eb8210d6eb2..269503701e6b 100644
@@ -500,8 +500,9 @@ static void recv_mode(int sk)
 					timestamp = 0;
 					memset(ts, 0, sizeof(ts));
 				} else {
-					sprintf(ts, "[%ld.%ld] ",
-							tv.tv_sec, tv.tv_usec);
+					sprintf(ts, "[%lld.%lld] ",
+							(long long)tv.tv_sec,
+							(long long)tv.tv_usec);
 				}
 			}
 
Signature · 1 line
2.35.3
#3 lore raw
In reply to Christian Eggers

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=679835

---Test result---

Test Summary:

CheckPatch                    PASS      2.07 seconds
GitLint                       PASS      1.40 seconds
Prep - Setup ELL              PASS      33.40 seconds
Build - Prep                  PASS      0.86 seconds
Build - Configure             PASS      10.63 seconds
Build - Make                  PASS      1109.03 seconds
Make Check                    PASS      13.06 seconds
Make Check w/Valgrind         PASS      357.62 seconds
Make Distcheck                PASS      304.53 seconds
Build w/ext ELL - Configure   PASS      10.74 seconds
Build w/ext ELL - Make        PASS      108.05 seconds
Incremental Build w/ patches  PASS      377.76 seconds
Scan Build                    WARNING   772.37 seconds

Details
##############################
Test: Scan Build - WARNING
Desc: Run Scan Build with patches
Output:
*****************************************************************************
The bugs reported by the scan-build may or may not be caused by your patches. Please check the list and fix the bugs if they are caused by your patch.
*****************************************************************************
monitor/analyze.c:381:2: warning: Value stored to 'data' is never read

        data += sizeof(*hdr);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:382:2: warning: Value stored to 'size' is never read
        size -= sizeof(*hdr);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:398:2: warning: Value stored to 'data' is never read
        data += sizeof(*evt);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:399:2: warning: Value stored to 'size' is never read
        size -= sizeof(*evt);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:418:2: warning: Value stored to 'data' is never read
        data += sizeof(*evt);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:419:2: warning: Value stored to 'size' is never read
        size -= sizeof(*evt);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:527:2: warning: Value stored to 'data' is never read
        data += sizeof(subtype);
        ^       ~~~~~~~~~~~~~~~
monitor/analyze.c:528:2: warning: Value stored to 'size' is never read
        size -= sizeof(subtype);
        ^       ~~~~~~~~~~~~~~~
monitor/analyze.c:629:2: warning: Value stored to 'data' is never read
        data += sizeof(*hdr);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:630:2: warning: Value stored to 'size' is never read
        size -= sizeof(*hdr);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:646:2: warning: Value stored to 'data' is never read
        data += sizeof(*hdr);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:647:2: warning: Value stored to 'size' is never read
        size -= sizeof(*hdr);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:710:2: warning: Value stored to 'data' is never read
        data += sizeof(*hdr);
        ^       ~~~~~~~~~~~~
monitor/analyze.c:711:2: warning: Value stored to 'size' is never read
        size -= sizeof(*hdr);
        ^       ~~~~~~~~~~~~
14 warnings generated.
monitor/packet.c:410:4: warning: Value stored to 'ts_pos' is never read
                        ts_pos += n;
                        ^         ~
monitor/packet.c:455:4: warning: Value stored to 'pos' is never read
                        pos += n;
                        ^      ~
monitor/packet.c:7477:2: warning: Value stored to 'mask' is never read
        mask = tx_phys;
        ^      ~~~~~~~
monitor/packet.c:7485:2: warning: Value stored to 'mask' is never read
        mask = rx_phys;
        ^      ~~~~~~~
monitor/packet.c:11229:3: warning: Value stored to 'str' is never read
                str = "AoA Constant Tone Extension";
                ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
monitor/packet.c:11232:3: warning: Value stored to 'str' is never read
                str = "AoA Constant Tone Extension with 1us slots";
                ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
monitor/packet.c:11235:3: warning: Value stored to 'str' is never read
                str = "AoD Constant Tone Extension with 2us slots";
                ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
monitor/packet.c:11238:3: warning: Value stored to 'str' is never read
                str = "No Constant Tone Extension";
                ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
monitor/packet.c:11241:3: warning: Value stored to 'str' is never read
                str = "Reserved";
                ^     ~~~~~~~~~~
monitor/packet.c:11242:3: warning: Value stored to 'color_on' is never read
                color_on = COLOR_RED;
                ^          ~~~~~~~~~

10 warnings generated.

---
Regards,
Linux Bluetooth

#4 lore raw
In reply to Christian Eggers
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 5 lines · On Fri, 23 Sep 2022 12:51:39 +0200 you wrote:

Use macros from inttypes.h for correct printf format specifier for int64_t

---
 client/player.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
- [BlueZ,1/3] client/player: fix printf format string

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7b07f1f98059
  - [BlueZ,2/3] monitor: fix printf format strings
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fa8411cf37a3
  - [BlueZ,3/3] tools: fix printf format strings
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e01e89179d4e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html