From: Thomas Weißschuh Date: Sat, 24 Dec 2022 16:32:50 +0000 (+0000) Subject: lib: procfs: fix error message during test X-Git-Tag: v2.39-rc1~356^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=758730c0b53f97282b324f88fc3d328efdf14468;p=thirdparty%2Futil-linux.git lib: procfs: fix error message during test procfs_process_get_stat_nth() returns the error and does not set errno. --- diff --git a/lib/procfs.c b/lib/procfs.c index e5c30ed578..e7a4cee80c 100644 --- a/lib/procfs.c +++ b/lib/procfs.c @@ -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);