From 1ddb0c6635638dffaa7ccf0c9642051738ceb981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Tue, 19 Feb 2008 23:59:07 +0000 Subject: [PATCH] Added error checking of the return value of get_sem_info(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24023 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/ps.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bin/ps.c b/src/bin/ps.c index c2b5fc7359..828d61522c 100644 --- a/src/bin/ps.c +++ b/src/bin/ps.c @@ -21,7 +21,6 @@ int main(int argc, char **argv) { - status_t ret; team_info teaminfo; thread_info thinfo; uint32 teamcookie = 0; @@ -36,7 +35,7 @@ int main(int argc, char **argv) puts(""); puts(PS_HEADER); puts(PS_SEP); - while ((ret = get_next_team_info(&teamcookie, &teaminfo)) >= B_OK) { + while (get_next_team_info(&teamcookie, &teaminfo) >= B_OK) { if (string_to_match) { char *p; p = teaminfo.args; @@ -50,15 +49,18 @@ int main(int argc, char **argv) } printf("%s (team %ld) (uid %d) (gid %d)\n", teaminfo.args, teaminfo.team, teaminfo.uid, teaminfo.gid); thcookie = 0; - while ((ret = get_next_thread_info(teaminfo.team, &thcookie, &thinfo)) >= B_OK) { + while (get_next_thread_info(teaminfo.team, &thcookie, &thinfo) >= B_OK) { if (thinfo.state < B_THREAD_RUNNING || thinfo.state >B_THREAD_WAITING) thstate = "???"; else thstate = states[thinfo.state-1]; printf("%7ld %20s %3s %3ld %7lli %7lli ", thinfo.thread, thinfo.name, thstate, thinfo.priority, thinfo.user_time/1000, thinfo.kernel_time/1000); if (thinfo.state == B_THREAD_WAITING) { - get_sem_info(thinfo.sem, &sinfo); - printf("%s(%ld)\n", sinfo.name, sinfo.sem); + status_t err = get_sem_info(thinfo.sem, &sinfo); + if (!err) + printf("%s(%ld)\n", sinfo.name, sinfo.sem); + else + printf("%s(%ld)\n", strerror(err), thinfo.sem); } else puts(""); }