ubase

suckless linux base utils
git clone git://git.2f30.org/ubase.git
Log | Files | Refs | README | LICENSE

commit 9e8a7ac61652d4cbe393701f1e15ee77c79a3466
parent f088b12877dec209eb7e02cf42b2761ed52d984e
Author: sin <sin@2f30.org>
Date:   Fri, 16 Aug 2013 15:51:37 +0100

Check return value of sysinfo()

Diffstat:
free.c | 3++-
ps.c | 3++-
uptime.c | 3++-
3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/free.c b/free.c @@ -24,7 +24,8 @@ main(int argc, char *argv[]) { struct sysinfo info; - sysinfo(&info); + if (sysinfo(&info) < 0) + eprintf("sysinfo:"); mem_unit = info.mem_unit ? info.mem_unit : 1; ARGBEGIN { diff --git a/ps.c b/ps.c @@ -122,7 +122,8 @@ psout(struct procstat *ps) if (errno || !pw) eprintf("getpwuid %d:", puid); - sysinfo(&info); + if (sysinfo(&info) < 0) + eprintf("sysinfo:"); start = time(NULL) - info.uptime; start += (ps->starttime / sysconf(_SC_CLK_TCK)); tm = localtime(&start); diff --git a/uptime.c b/uptime.c @@ -29,7 +29,8 @@ main(int argc, char *argv[]) usage(); } ARGEND; - sysinfo(&info); + if (sysinfo(&info) < 0) + eprintf("sysinfo:"); time(&tmptime); now = localtime(&tmptime); printf(" %02d:%02d:%02d up ", now->tm_hour, now->tm_min, now->tm_sec);