diff --git a/lib/common/tests/procfs/pcmk__procfs_has_pids_false_test.c b/lib/common/tests/procfs/pcmk__procfs_has_pids_false_test.c index 4601aac9df..9fc73bc5df 100644 --- a/lib/common/tests/procfs/pcmk__procfs_has_pids_false_test.c +++ b/lib/common/tests/procfs/pcmk__procfs_has_pids_false_test.c @@ -1,42 +1,40 @@ /* - * Copyright 2022 the Pacemaker project contributors + * Copyright 2022-2025 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU General Public License version 2 * or later (GPLv2+) WITHOUT ANY WARRANTY. */ #include #include #include "mock_private.h" #include #include #include - static void no_pids(void **state) { - char path[PATH_MAX]; - - snprintf(path, PATH_MAX, "/proc/%u/exe", getpid()); + char *exe_path = crm_strdup_printf("/proc/%lld/exe", (long long) getpid()); // Set readlink() errno and link contents (for /proc/PID/exe) pcmk__mock_readlink = true; - expect_string(__wrap_readlink, path, path); + expect_string(__wrap_readlink, path, exe_path); expect_any(__wrap_readlink, buf); expect_value(__wrap_readlink, bufsize, PATH_MAX - 1); will_return(__wrap_readlink, ENOENT); will_return(__wrap_readlink, NULL); assert_false(pcmk__procfs_has_pids()); pcmk__mock_readlink = false; + free(exe_path); } PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(no_pids)) diff --git a/lib/common/tests/procfs/pcmk__procfs_has_pids_true_test.c b/lib/common/tests/procfs/pcmk__procfs_has_pids_true_test.c index 758e3b905c..65a4a320bd 100644 --- a/lib/common/tests/procfs/pcmk__procfs_has_pids_true_test.c +++ b/lib/common/tests/procfs/pcmk__procfs_has_pids_true_test.c @@ -1,41 +1,40 @@ /* - * Copyright 2022 the Pacemaker project contributors + * Copyright 2022-2025 the Pacemaker project contributors * * The version control history for this file may have further details. * * This source code is licensed under the GNU General Public License version 2 * or later (GPLv2+) WITHOUT ANY WARRANTY. */ #include #include #include "mock_private.h" #include #include #include static void has_pids(void **state) { - char path[PATH_MAX]; - - snprintf(path, PATH_MAX, "/proc/%u/exe", getpid()); + char *exe_path = crm_strdup_printf("/proc/%lld/exe", (long long) getpid()); // Set readlink() errno and link contents (for /proc/PID/exe) pcmk__mock_readlink = true; - expect_string(__wrap_readlink, path, path); + expect_string(__wrap_readlink, path, exe_path); expect_any(__wrap_readlink, buf); expect_value(__wrap_readlink, bufsize, PATH_MAX - 1); will_return(__wrap_readlink, 0); will_return(__wrap_readlink, "/ok"); assert_true(pcmk__procfs_has_pids()); pcmk__mock_readlink = false; + free(exe_path); } PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(has_pids))