Commit Graph

9 Commits

Author SHA1 Message Date
Jim Warner
88daa89883 miscellaneous: silence a whole bunch of clang warnings
[ but most definitely not all of them by a long shot ]

Reference(s):
proc/diskstat.c:186:17: warning: unused variable 'is_disk' [-Wunused-variable]
    int retval, is_disk;
                ^
proc/namespace.c:110:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
proc/readproc.c:1131:50: warning: address of array 'ent->d_name' will always evaluate to 'true' [-Wpointer-bo
    if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0;
                                           ~~~~~~^~~~~~
proc/readproc.c:1158:50: warning: address of array 'ent->d_name' will always evaluate to 'true' [-Wpointer-bo
    if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0;
                                           ~~~~~~^~~~~~
proc/sysinfo.c:45:12: warning: unused variable 'stat_fd' [-Wunused-variable]
static int stat_fd = -1;
           ^
proc/sysinfo.c:49:12: warning: unused variable 'meminfo_fd' [-Wunused-variable]
static int meminfo_fd = -1;
           ^
proc/sysinfo.c:51:12: warning: unused variable 'vminfo_fd' [-Wunused-variable]
static int vminfo_fd = -1;
           ^
proc/sysinfo.c:53:12: warning: unused variable 'vm_min_free_fd' [-Wunused-variable]
static int vm_min_free_fd = -1;
           ^
proc/uptime.c:157:12: warning: unused variable 'realseconds' [-Wunused-variable]
    time_t realseconds;
           ^
proc/uptime.c:158:16: warning: unused variable 'realtime' [-Wunused-variable]
    struct tm *realtime;
               ^
vmstat.c:574:20: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
                   DSTAT(PROCPS_DISKSTAT_READ_TIME),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vmstat.c:578:20: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
                   DSTAT(PROCPS_DISKSTAT_WRITE_TIME),
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
watch.c:230:7: warning: variable 'endptr' is uninitialized when used here [-Wuninitialized]
        if (*endptr == '\0') set_ansi_attribute(0); /* [m treated as [0m */
             ^~~~~~

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-09-21 22:34:27 +10:00
Craig Small
617a4d0f70 library: Add space after days for uptime
Uptime output for both w and uptime command were showing no
comma or space after days.

$ ./uptime
 18:32:21 up 22 days7 min,  6 users,  load average: 0.23, 0.46, 0.64

Minor tweak to fix this.
2015-09-07 18:38:39 +10:00
Jim Warner
34395be330 library: suppress zero 'days' under the <uptime.h> API
The former whattime logic used to suppress that 'days'
output when the system had been up less than 24 hours.

But since the refactor for newlib, '0 days' was always
output under those conditions. So this commit restores
the former expected behavior of suppressing that item.

[ plus an erroneous calculation of uphours was fixed ]

[ and the clang warnings shown below were also fixed ]

Reference(s):
proc/uptime.c:74:10: warning: unused variable 'buf' [-Wunused-variable]
    char buf[256];
         ^
proc/uptime.c:131:58: warning: data argument not used by format string [-Wformat-extra-args]
        pos += sprintf(upbuf + pos, "%d min, ", uphours, upminutes);
                                    ~~~~~~~~~~           ^
proc/uptime.c:175:15: warning: expression result unused [-Wunused-value]
        comma +1;
        ~~~~~ ^~

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-09-06 21:59:17 +10:00
Craig Small
c3e85cef73 library: loadavg change to procps_loadavg 2015-07-01 21:47:30 +10:00
Jim Warner
336748ecc0 misc: remove yet more darn trailing whitespace buildup
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:28:22 +10:00
Craig Small
639daf5468 library: Update uptime calls to standard format
Changed all the uptime related functions to use the
standard naming procps_uptime_*
2015-06-29 22:09:59 +10:00
Craig Small
cbf25b93e3 library: more mem and stat fixes
Make distcheck now succeeds.
Changed some of the binaries to use the new API.
2015-06-26 22:37:29 +10:00
Craig Small
05efbebb66 library: Fix up stat API
Adjusted vmstat to use the new API for memory and CPU statistics
2015-06-26 22:37:28 +10:00
Craig Small
d7932b9a13 library: uptime API changes
Removed the printf_uptime, binaries can do printf easily enough.
sprint_uptime split into two as there wasn't a lot of common
code
 sprint_uptime(): old style uptime line
 sprint_uptime_short(): short new style "uptime -p"

Hertz_hack needed this, no sane system uses the code (I think)
so just assume 100 like we do in FreeBSD.
2015-06-26 22:37:28 +10:00