2022-07-01 00:53:09

by Tedd Ho-Jeong An

[permalink] [raw]
Subject: [PATCH BlueZ 2/2] tools/test-runner: Fix errors reported by scan-build

From: Tedd Ho-Jeong An <[email protected]>

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