Skip to contentSkip to conversation

tools/btpclient: Fix compile warning with strncpy

PATCH Applied Tedd Ho-Jeong An 2 participants 2 messages Nov 29, 2018 – Dec 4, 2018 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/btpclient: Fix compile warning with strncpy

This patch fixes the boundry warning-to-error in GCC 8.1.1 with strncpy.

---
 tools/btpclient.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/btpclient.c +2 -2
index b217df58f..e77720ed1 100644
@@ -376,8 +376,8 @@ static void btp_gap_read_info(uint8_t index, const void *param, uint16_t length,
 		goto failed;
 	}
 
-	strncpy((char *) rp.name, str, sizeof(rp.name));
-	strncpy((char *) rp.short_name, str, sizeof(rp.short_name));
+	snprintf((char *)rp.name, sizeof(rp.name), "%s", str);
+	snprintf((char *)rp.short_name, sizeof(rp.short_name), "%s", str);
 	rp.supported_settings = L_CPU_TO_LE32(adapter->supported_settings);
 	rp.current_settings = L_CPU_TO_LE32(adapter->current_settings);
 
Signature · 1 line
2.17.2
maintainer Applied
#1 lore raw

Hi Tedd,

Quoted 22 lines · Tedd Ho-Jeong An

This patch fixes the boundry warning-to-error in GCC 8.1.1 with strncpy.

---
 tools/btpclient.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/btpclient.c +2 -3
index b217df58f..e77720ed1 100644
@@ -376,8 +376,8 @@ static void btp_gap_read_info(uint8_t index, const void *param, uint16_t length,
                goto failed;
        }
 
-       strncpy((char *) rp.name, str, sizeof(rp.name));
-       strncpy((char *) rp.short_name, str, sizeof(rp.short_name));
+       snprintf((char *)rp.name, sizeof(rp.name), "%s", str);
+       snprintf((char *)rp.short_name, sizeof(rp.short_name), "%s", str);
        rp.supported_settings = L_CPU_TO_LE32(adapter->supported_settings);
        rp.current_settings = L_CPU_TO_LE32(adapter->current_settings);
 
--
Quoted 1 line

2.17.2

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz