All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] tools/btmgmt: Fix errors reported by scan-build
@ 2022-07-01  0:43 Tedd Ho-Jeong An
  2022-07-01  0:43 ` [PATCH BlueZ 2/2] tools/test-runner: " Tedd Ho-Jeong An
  2022-07-02  0:29 ` [PATCH BlueZ 1/2] tools/btmgmt: " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Tedd Ho-Jeong An @ 2022-07-01  0:43 UTC (permalink / raw)
  To: linux-bluetooth

From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch fixes the errors reported by the scan-build.

tools/btmgmt.c:2699:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:2859:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:2860:2: warning: Value stored to 'argv' is never read
[deadcode.DeadStores]
        argv += optind;
        ^       ~~~~~~

tools/btmgmt.c:2934:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:2935:2: warning: Value stored to 'argv' is never read
[deadcode.DeadStores]
        argv += optind;
        ^       ~~~~~~

tools/btmgmt.c:3000:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:3001:2: warning: Value stored to 'argv' is never read
[deadcode.DeadStores]
        argv += optind;
        ^       ~~~~~~

tools/btmgmt.c:3261:11: warning: Value stored to 'index' during its
initialization is never read [deadcode.DeadStores]
        uint16_t index = mgmt_index;
                 ^~~~~   ~~~~~~~~~~

tools/btmgmt.c:3450:2: warning: Value stored to 'argc' is never read
[deadcode.DeadStores]
        argc -= optind;
        ^       ~~~~~~

tools/btmgmt.c:3451:2: warning: Value stored to 'argv' is never read
[deadcode.DeadStores]
        argv += optind;
        ^       ~~~~~~

tools/btmgmt.c:4822:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + uuid_bytes, adv_data, adv_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/btmgmt.c:4823:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/btmgmt.c:5244:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + uuid_bytes, adv_data, adv_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/btmgmt.c:5245:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 tools/btmgmt.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 3bf2c21c1..ebef3888f 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2696,7 +2696,6 @@ static void cmd_disconnect(int argc, char **argv)
 		}
 	}
 
-	argc -= optind;
 	argv += optind;
 	optind = 0;
 
@@ -2856,8 +2855,6 @@ static void cmd_find_service(int argc, char **argv)
 		}
 	}
 
-	argc -= optind;
-	argv += optind;
 	optind = 0;
 
 	cp = (void *) buf;
@@ -2931,8 +2928,6 @@ static void cmd_find(int argc, char **argv)
 		}
 	}
 
-	argc -= optind;
-	argv += optind;
 	optind = 0;
 
 	memset(&cp, 0, sizeof(cp));
@@ -2997,8 +2992,6 @@ static void cmd_stop_find(int argc, char **argv)
 		}
 	}
 
-	argc -= optind;
-	argv += optind;
 	optind = 0;
 
 	memset(&cp, 0, sizeof(cp));
@@ -3258,7 +3251,7 @@ static void cmd_unpair(int argc, char **argv)
 	struct mgmt_cp_unpair_device cp;
 	uint8_t type = BDADDR_BREDR;
 	int opt;
-	uint16_t index = mgmt_index;
+	uint16_t index;
 
 	while ((opt = getopt_long(argc, argv, "+t:h", unpair_options,
 								NULL)) != -1) {
@@ -3447,8 +3440,6 @@ static void cmd_irks(int argc, char **argv)
 		}
 	}
 
-	argc -= optind;
-	argv += optind;
 	optind = 0;
 
 	cp->irk_count = cpu_to_le16(count);
@@ -4819,8 +4810,11 @@ static void cmd_add_adv(int argc, char **argv)
 		memcpy(cp->data + 2, uuids, uuid_bytes - 2);
 	}
 
-	memcpy(cp->data + uuid_bytes, adv_data, adv_len);
-	memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
+	if (adv_len)
+		memcpy(cp->data + uuid_bytes, adv_data, adv_len);
+
+	if (scan_rsp_len)
+		memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
 
 	if (!mgmt_send(mgmt, MGMT_OP_ADD_ADVERTISING, index, cp_len, cp,
 						add_adv_rsp, NULL, NULL)) {
@@ -5241,8 +5235,11 @@ static void cmd_add_ext_adv_data(int argc, char **argv)
 		memcpy(cp->data + 2, uuids, uuid_bytes - 2);
 	}
 
-	memcpy(cp->data + uuid_bytes, adv_data, adv_len);
-	memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
+	if (adv_len)
+		memcpy(cp->data + uuid_bytes, adv_data, adv_len);
+
+	if (scan_rsp_len)
+		memcpy(cp->data + uuid_bytes + adv_len, scan_rsp, scan_rsp_len);
 
 	if (!mgmt_send(mgmt, MGMT_OP_ADD_EXT_ADV_DATA, index, cp_len, cp,
 					add_ext_adv_data_rsp, NULL, NULL)) {
-- 
2.34.1


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

* [PATCH BlueZ 2/2] tools/test-runner: Fix errors reported by scan-build
  2022-07-01  0:43 [PATCH BlueZ 1/2] tools/btmgmt: Fix errors reported by scan-build Tedd Ho-Jeong An
@ 2022-07-01  0:43 ` Tedd Ho-Jeong An
  2022-07-02  0:29 ` [PATCH BlueZ 1/2] tools/btmgmt: " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: Tedd Ho-Jeong An @ 2022-07-01  0:43 UTC (permalink / raw)
  To: linux-bluetooth

From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch fixes the errors reported by the scan-build.

tools/test-runner.c:315:2: warning: Null pointer passed to 1st parameter
expecting 'nonnull' [core.NonNullParamChecker]
        execve(argv[0], argv, qemu_envp);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tools/test-runner.c:554:6: warning: Null pointer passed to 1st parameter
expecting 'nonnull' [core.NonNullParamChecker]
        if (chdir(home + 5) < 0) {
            ^~~~~~~~~~~~~~~

tools/test-runner.c:638:6: warning: Null pointer passed to 1st parameter
expecting 'nonnull' [core.NonNullParamChecker]
        if (chdir(home + 5) < 0) {
            ^~~~~~~~~~~~~~~

tools/test-runner.c:695:6: warning: Null pointer passed to 1st parameter
expecting 'nonnull' [core.NonNullParamChecker]
        if (chdir(home + 5) < 0) {
            ^~~~~~~~~~~~~~~

tools/test-runner.c:984:3: warning: Value stored to 'serial_fd' is never
read [deadcode.DeadStores]
                serial_fd = -1;
                ^           ~~
---
 tools/test-runner.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/test-runner.c b/tools/test-runner.c
index 6886d66c6..5ab8e57a0 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -269,6 +269,11 @@ static void start_qemu(void)
 
 	pos = (sizeof(qemu_argv) / sizeof(char *)) - 1;
 
+	/* Make sure qemu_binary is not null */
+	if (!qemu_binary) {
+		fprintf(stderr, "No QEMU binary is set\n");
+		exit(1);
+	}
 	argv[0] = (char *) qemu_binary;
 
 	if (audio_support) {
@@ -800,6 +805,11 @@ static void run_command(char *cmdname, char *home)
 	pid_t pid, dbus_pid, daemon_pid, monitor_pid, emulator_pid,
 	      dbus_session_pid, udevd_pid;
 
+	if (!home) {
+		perror("Invalid parameter: TESTHOME");
+		return;
+	}
+
 	if (num_devs) {
 		const char *node = "/dev/ttyS1";
 		unsigned int basic_flags, extra_flags;
@@ -979,10 +989,8 @@ start_next:
 	if (udevd_pid > 0)
 		kill(udevd_pid, SIGTERM);
 
-	if (serial_fd >= 0) {
+	if (serial_fd >= 0)
 		close(serial_fd);
-		serial_fd = -1;
-	}
 }
 
 static void run_tests(void)
-- 
2.34.1


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

* Re: [PATCH BlueZ 1/2] tools/btmgmt: Fix errors reported by scan-build
  2022-07-01  0:43 [PATCH BlueZ 1/2] tools/btmgmt: Fix errors reported by scan-build Tedd Ho-Jeong An
  2022-07-01  0:43 ` [PATCH BlueZ 2/2] tools/test-runner: " Tedd Ho-Jeong An
@ 2022-07-02  0:29 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2022-07-02  0:29 UTC (permalink / raw)
  To: Tedd Ho-Jeong An; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 30 Jun 2022 17:43:51 -0700 you wrote:
> From: Tedd Ho-Jeong An <tedd.an@intel.com>
> 
> This patch fixes the errors reported by the scan-build.
> 
> tools/btmgmt.c:2699:2: warning: Value stored to 'argc' is never read
> [deadcode.DeadStores]
>         argc -= optind;
>         ^       ~~~~~~
> 
> [...]

Here is the summary with links:
  - [BlueZ,1/2] tools/btmgmt: Fix errors reported by scan-build
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c1f0b1a747bc
  - [BlueZ,2/2] tools/test-runner: Fix errors reported by scan-build
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=dd12ff1ed1f0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-07-02  0:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-01  0:43 [PATCH BlueZ 1/2] tools/btmgmt: Fix errors reported by scan-build Tedd Ho-Jeong An
2022-07-01  0:43 ` [PATCH BlueZ 2/2] tools/test-runner: " Tedd Ho-Jeong An
2022-07-02  0:29 ` [PATCH BlueZ 1/2] tools/btmgmt: " patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.