Linux-Bluetooth Archive on lore.kernel.org
 help / Atom feed
* [PATCH] tools/btpclient: Fix compile warning with strncpy
@ 2018-11-29 23:24 Tedd Ho-Jeong An
  2018-12-04 20:06 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Tedd Ho-Jeong An @ 2018-11-29 23:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: grzegorz.kolodziejczyk, ruslan.mstoi

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(-)

diff --git a/tools/btpclient.c b/tools/btpclient.c
index b217df58f..e77720ed1 100644
--- a/tools/btpclient.c
+++ b/tools/btpclient.c
@@ -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);
 
-- 
2.17.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] tools/btpclient: Fix compile warning with strncpy
  2018-11-29 23:24 [PATCH] tools/btpclient: Fix compile warning with strncpy Tedd Ho-Jeong An
@ 2018-12-04 20:06 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2018-12-04 20:06 UTC (permalink / raw)
  To: An, Tedd; +Cc: linux-bluetooth, Grzegorz Kolodziejczyk, ruslan.mstoi

Hi Tedd,
On Fri, Nov 30, 2018 at 1:26 AM Tedd Ho-Jeong An <tedd.an@intel.com> wrote:
>
> 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(-)
>
> diff --git a/tools/btpclient.c b/tools/btpclient.c
> index b217df58f..e77720ed1 100644
> --- a/tools/btpclient.c
> +++ b/tools/btpclient.c
> @@ -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);
>
> --
> 2.17.2

Applied, thanks.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29 23:24 [PATCH] tools/btpclient: Fix compile warning with strncpy Tedd Ho-Jeong An
2018-12-04 20:06 ` Luiz Augusto von Dentz

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable: git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org linux-bluetooth@archiver.kernel.org
	public-inbox-index linux-bluetooth


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/ public-inbox