]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib: procfs: fix error message during test
authorThomas Weißschuh <thomas@t-8ch.de>
Sat, 24 Dec 2022 16:32:50 +0000 (16:32 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 24 Dec 2022 17:00:45 +0000 (17:00 +0000)
procfs_process_get_stat_nth() returns the error and does not set errno.

lib/procfs.c

index e5c30ed5787c2a4e7bff72d96ac197a7ef23ee5c..e7a4cee80c2de421a1c6c21b91a588138bb93d55 100644 (file)
@@ -581,7 +581,7 @@ static int test_process_stat_nth(int argc, char *argv[])
        pid_t pid;
        struct path_cxt *pc;
        uintmax_t num = 0;
-       int n;
+       int n, ret;
 
        if (argc != 3)
                return EXIT_FAILURE;
@@ -592,8 +592,9 @@ static int test_process_stat_nth(int argc, char *argv[])
        if (!pc)
                err(EXIT_FAILURE, "cannot alloc procfs handler");
 
-       if (procfs_process_get_stat_nth(pc, n, &num) != 0)
-               err(EXIT_FAILURE, "read %dth number failed", n);
+       ret = procfs_process_get_stat_nth(pc, n, &num);
+       if (ret)
+               errx(EXIT_FAILURE, "read %dth number failed: %s", n, strerror(-ret));
 
        printf("%d: %dth %ju\n", (int) pid, n, num);
        ul_unref_path(pc);