From: Francis Deslauriers Date: Thu, 22 Apr 2021 21:24:57 +0000 (-0400) Subject: Fix: tests: gen-ust-events-ns: Uninitialized argument value X-Git-Tag: v2.13.0-rc1~11 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3ad7f5fefc1265d35673e5dcb9358c9c9bf6193f;p=lttng-tools.git Fix: tests: gen-ust-events-ns: Uninitialized argument value If both `if (snprintf(...` of the `get_ns_inum()` function fail, the function will not uninitialize the `ns_inum` output parameter and still return 0. Leading to the argument `ns1` of debug_printf() being used uninitialized. Reported-by: scan-build. Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: I47286312095ca0f6a889eb0faa93661f92156ec1 --- diff --git a/tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.c b/tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.c index 907651d7c..dadfc3d3a 100644 --- a/tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.c +++ b/tests/utils/testapp/gen-ust-events-ns/gen-ust-events-ns.c @@ -91,7 +91,7 @@ static void debug_printf(const char *format, ...) static int get_ns_inum(const char *ns, ino_t *ns_inum) { - int ret = 0; + int ret = -1; struct stat sb; char proc_ns_path[LTTNG_PROC_NS_PATH_MAX]; @@ -102,8 +102,7 @@ static int get_ns_inum(const char *ns, ino_t *ns_inum) "/proc/thread-self/ns/%s", ns) >= 0) { if (stat(proc_ns_path, &sb) == 0) { *ns_inum = sb.st_ino; - } else { - ret = -1; + ret = 0; } goto end; } @@ -112,8 +111,7 @@ static int get_ns_inum(const char *ns, ino_t *ns_inum) "/proc/self/task/%d/%s/net", lttng_gettid(), ns) >= 0) { if (stat(proc_ns_path, &sb) == 0) { *ns_inum = sb.st_ino; - } else { - ret = -1; + ret = 0; } goto end; }