From 758730c0b53f97282b324f88fc3d328efdf14468 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 24 Dec 2022 16:32:50 +0000 Subject: [PATCH] lib: procfs: fix error message during test procfs_process_get_stat_nth() returns the error and does not set errno. --- lib/procfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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); -- 2.47.3