Hello community,

here is the log from the commit of package cpustat for openSUSE:Factory checked 
in at 2018-09-05 13:49:59
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/cpustat (Old)
 and      /work/SRC/openSUSE:Factory/.cpustat.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "cpustat"

Wed Sep  5 13:49:59 2018 rev:4 rq:633277 version:0.02.05

Changes:
--------
--- /work/SRC/openSUSE:Factory/cpustat/cpustat.changes  2018-02-06 
16:51:29.661494825 +0100
+++ /work/SRC/openSUSE:Factory/.cpustat.new/cpustat.changes     2018-09-05 
13:50:03.406408770 +0200
@@ -1,0 +2,16 @@
+Wed Sep  5 06:17:28 UTC 2018 - lie...@rz.uni-mannheim.de
+
+- update to version 0.02.05
+  * Fix leading zeros on time data
+  * Fix the time scaling, use base 60 where necessary
+  * Add more constifcations to functions and arrays
+  * Minor code clean ups
+  * constify cpu_freq_scale
+  * voidify function returns
+  * debian/control: set debhelper version >= 11
+  * debian/compat: set to 11
+  * debian/control: remove empty line at end of file
+  * debian/copyright: use secure URI
+  * Makefile: bump version
+
+-------------------------------------------------------------------

Old:
----
  cpustat-0.02.04.tar.gz

New:
----
  cpustat-0.02.05.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ cpustat.spec ++++++
--- /var/tmp/diff_new_pack.62lHEa/_old  2018-09-05 13:50:03.930409649 +0200
+++ /var/tmp/diff_new_pack.62lHEa/_new  2018-09-05 13:50:03.934409656 +0200
@@ -18,10 +18,10 @@
 
 
 Name:           cpustat
-Version:        0.02.04
+Version:        0.02.05
 Release:        0
 Summary:        Periodic cpu utilization statistics
-License:        GPL-2.0+
+License:        GPL-2.0-or-later
 Group:          System/Monitoring
 Url:            http://kernel.ubuntu.com/~cking/cpustat/
 Source:         
http://kernel.ubuntu.com/~cking/tarballs/%{name}/%{name}-%{version}.tar.gz

++++++ cpustat-0.02.04.tar.gz -> cpustat-0.02.05.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cpustat-0.02.04/Makefile new/cpustat-0.02.05/Makefile
--- old/cpustat-0.02.04/Makefile        2018-01-31 11:52:34.000000000 +0100
+++ new/cpustat-0.02.05/Makefile        2018-06-14 20:17:06.000000000 +0200
@@ -18,7 +18,7 @@
 # Author: Colin Ian King <colin.k...@canonical.com>
 #
 
-VERSION=0.02.04
+VERSION=0.02.05
 
 CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' -O2
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cpustat-0.02.04/cpustat.c 
new/cpustat-0.02.05/cpustat.c
--- old/cpustat-0.02.04/cpustat.c       2018-01-31 11:52:34.000000000 +0100
+++ new/cpustat-0.02.05/cpustat.c       2018-06-14 20:17:06.000000000 +0200
@@ -187,8 +187,9 @@
 /* scaling factor */
 typedef struct {
        const char ch;                  /* Scaling suffix */
+       const uint32_t base;            /* Base of part following . point */
        const uint64_t scale;           /* Amount to scale by */
-} scale_t;
+} time_scale_t;
 
 typedef struct {
        uint32_t hash;                  /* Hash of /proc/stat field tag */
@@ -206,8 +207,8 @@
        void (*df_linebreak)(void);
 } display_funcs_t;
 
-/* CPU frequency scale suffixes */
-static cpu_freq_scale_t cpu_freq_scale[] = {
+/* CPU frequency  scale suffixes */
+static const cpu_freq_scale_t cpu_freq_scale[] = {
        { 1e1,  1e0,  "Hz" },
        { 1e4,  1e3,  "KHz" },
        { 1e7,  1e6,  "MHz" },
@@ -217,14 +218,14 @@
 };
 
 /* seconds scale suffixes, secs, mins, hours, etc */
-static const scale_t second_scales[] = {
-       { 's',  1 },
-       { 'm',  60 },
-       { 'h',  3600 },
-       { 'd',  24 * 3600 },
-       { 'w',  7 * 24 * 3600 },
-       { 'y',  365 * 24 * 3600 },
-       { ' ',  INT64_MAX },
+static const time_scale_t second_scales[] = {
+       { 's',  100, 1 },
+       { 'm',   60, 60 },
+       { 'h',   60, 3600 },
+       { 'd',  100, 24 * 3600 },
+       { 'w',  100, 7 * 24 * 3600 },
+       { 'y',  100, 365 * 24 * 3600 },
+       { ' ',  100,  INT64_MAX },
 };
 
 static const proc_stat_fields_t fields[] = {
@@ -370,7 +371,11 @@
  *     put a decimal value v into string str with max
  *     length of nbytes
  */
-static int OPTIMIZE3 HOT putint(char *str, int nbytes, int v, bool zeropad)
+static int OPTIMIZE3 HOT putint(
+       char * const str,
+       int nbytes,
+       int v,
+       const bool zeropad)
 {
         register char *ptr = str + nbytes;
        int ret = nbytes;
@@ -397,7 +402,7 @@
  *     put unsigned decimal value v into str
  *      with no leading spaces.
  */
-static int OPTIMIZE3 HOT putuint(char *str, unsigned int v)
+static int OPTIMIZE3 HOT putuint(char *const str, unsigned int v)
 {
        register char *ptr = str;
        register char *p1, *p2, *mid;
@@ -425,13 +430,16 @@
  *  putdouble()
  *     put a double in %6.2 with trailing space
  */
-static int OPTIMIZE3 HOT putdouble(char *str, double v)
+static int OPTIMIZE3 HOT putdouble(
+       char *str,
+       const double val,
+       const int base)
 {
-       v += 0.005;     /* Round up */
+       const double v = val + 0.005; /* Round up */
 
        (void)putint(str, 3, (int)v, false);
        str[3] = '.';
-       (void)putint(str + 4, 2, v * 100.0 - (double)((int)v * 100), true);
+       (void)putint(str + 4, 2, v * (double)base - (double)((int)v * base), 
true);
        str[2] = (str[2] == ' ') ? '0' : str[2];
        str[6] = ' ';
        str[7] = '\0';
@@ -443,7 +451,10 @@
  *  putdouble_decpl
  *     put a double with decpl number of decimal places with trailing space, 
up to 4 decpl
  */
-static int OPTIMIZE3 HOT putdouble_decpl(char *str, double v, int decpl)
+static int OPTIMIZE3 HOT putdouble_decpl(
+       char * const str,
+       double v,
+       int decpl)
 {
        char *ptr = str;
        static const double scales[] = {
@@ -471,7 +482,7 @@
  *  putstr()
  *     append a string and return bytes added
  */
-static int OPTIMIZE3 HOT putstr(char *dst, int max, char *src)
+static int OPTIMIZE3 HOT putstr(char *dst, const int max, char *src)
 {
        register int n = 0;
 
@@ -487,19 +498,19 @@
  */
 static void cpustat_top_setup(void)
 {
-       initscr();
-       cbreak();
-       noecho();
-       nodelay(stdscr, 1);
-       keypad(stdscr, 1);
-       curs_set(0);
+       (void)initscr();
+       (void)cbreak();
+       (void)noecho();
+       (void)nodelay(stdscr, 1);
+       (void)keypad(stdscr, 1);
+       (void)curs_set(0);
 }
 
 /*
  *  cpustat_generic_winsize()
  *     get tty size in top mode
  */
-static void cpustat_generic_winsize(bool redo)
+static void cpustat_generic_winsize(const bool redo)
 {
        if (redo) {
                struct winsize ws;
@@ -514,12 +525,12 @@
        }
 }
 
-static void cpustat_top_winsize(bool redo)
+static void cpustat_top_winsize(const bool redo)
 {
        (void)redo;
 
        cpustat_generic_winsize(true);
-       resizeterm(rows, cols);
+       (void)resizeterm(rows, cols);
 }
 
 /*
@@ -538,11 +549,11 @@
 static void cpustat_top_endwin(void)
 {
        df.df_winsize(true);
-       resizeterm(rows, cols);
-       refresh();
+       (void)resizeterm(rows, cols);
+       (void)refresh();
        resized = false;
-       clear();
-       endwin();
+       (void)clear();
+       (void)endwin();
 }
 
 /*
@@ -551,7 +562,7 @@
  */
 static inline void cpustat_top_clear(void)
 {
-       clear();
+       (void)clear();
 }
 
 /*
@@ -560,7 +571,7 @@
  */
 static inline void cpustat_top_refresh(void)
 {
-       refresh();
+       (void)refresh();
 }
 
 /*
@@ -568,28 +579,27 @@
  *     cpustat put string in top mode with newline
  *     (or not if there is potential for line wrap)
  */
-static void cpustat_top_putstrnl(char *str, int n)
+static void cpustat_top_putstrnl(char * const str, const int n)
 {
        if (UNLIKELY(cury >= rows))
                return;
 
        if (UNLIKELY(n > cols)) {
-               n = cols;
-               str[n] = '\0';
+               str[cols] = '\0';
        } else {
                str[n] = '\n';
                str[n + 1] = '\0';
        }
 
        cury++;
-       addstr(str);
+       (void)addstr(str);
 }
 
 /*
  *  cpustat_normal_putstr(()
  *     cpustat put string in normal mode with newline
  */
-static void cpustat_normal_putstrnl(char *str, int n)
+static void cpustat_normal_putstrnl(char * const str, int n)
 {
        if (UNLIKELY(n > cols))
                n = cols;
@@ -597,7 +607,7 @@
        str[n] = '\n';
        str[n + 1] = '\0';
 
-       fputs(str, stdout);
+       (void)fputs(str, stdout);
 }
 
 /*
@@ -606,11 +616,11 @@
  */
 static void cpustat_normal_linebreak(void)
 {
-       putc('\n', stdout);
+       (void)putc('\n', stdout);
 }
 
 /* 'top' mode display functions */
-static display_funcs_t df_top = {
+static const display_funcs_t df_top = {
        cpustat_top_setup,
        cpustat_top_endwin,
        cpustat_top_clear,
@@ -621,7 +631,7 @@
 };
 
 /* normal tty mode display functions */
-static display_funcs_t df_normal = {
+static const display_funcs_t df_normal = {
        cpustat_noop,
        cpustat_noop,
        cpustat_noop,
@@ -706,12 +716,15 @@
 {
        static char buf[16];
        size_t i;
+       double s = secs;
 
        for (i = 0; i < 5; i++) {
-               if (secs <= second_scales[i + 1].scale)
+               if (s <= second_scales[i + 1].scale)
                        break;
        }
-       putdouble(buf, secs / second_scales[i].scale);
+       s /= second_scales[i].scale;
+
+       (void)putdouble(buf, s, second_scales[i].base);
        buf[6] = second_scales[i].ch;
 
        return buf;
@@ -721,7 +734,7 @@
  *  get_tm()
  *     fetch tm, will set fields to zero if can't get
  */
-static void get_tm(const double time_now, struct tm *tm)
+static void get_tm(const double time_now, struct tm * const tm)
 {
        time_t now = (time_t)time_now;
 
@@ -747,7 +760,7 @@
  */
 static inline void double_to_timeval(
        const double val,
-       struct timeval *tv)
+       struct timeval * const tv)
 {
        tv->tv_sec = val;
        tv->tv_usec = (val - (time_t)val) * 1000000.0;
@@ -762,7 +775,7 @@
        struct timeval tv;
 
         if (UNLIKELY(gettimeofday(&tv, NULL) < 0)) {
-                fprintf(stderr, "gettimeofday failed: errno=%d (%s)\n",
+                (void)fprintf(stderr, "gettimeofday failed: errno=%d (%s)\n",
                         errno, strerror(errno));
                 exit(EXIT_FAILURE);
         }
@@ -825,7 +838,7 @@
        ptr = path;
        ptr += putstr(ptr, 6, "/proc/");
        ptr += putuint(ptr, pid);
-       putstr(ptr, 8, "/cmdline");
+       (void)putstr(ptr, 8, "/cmdline");
        ptr = NULL;
 
        if (UNLIKELY((fd = open(path, O_RDONLY)) < 0))
@@ -978,7 +991,7 @@
         */
        if (!found) {
                if (UNLIKELY((sdl = malloc(sizeof(*sdl))) == NULL)) {
-                       fprintf(stderr, "Cannot allocate sample delta list\n");
+                       (void)fprintf(stderr, "Cannot allocate sample delta 
list\n");
                        exit(EXIT_FAILURE);
                }
                sdl->next = NULL;
@@ -995,7 +1008,7 @@
 
        /* Now append the sdi onto the list */
        if (UNLIKELY((sdi = malloc(sizeof(*sdi))) == NULL)) {
-               fprintf(stderr, "Cannot allocate sample delta item\n");
+               (void)fprintf(stderr, "Cannot allocate sample delta item\n");
                exit(EXIT_FAILURE);
        }
        sdi->next = sdl->sample_delta_item_list;
@@ -1051,11 +1064,11 @@
 
        if (!hdrptr) {
                hdrptr = str;
-               strncpy(hdrptr, "  %CPU   %USR   %SYS   ", sizeof(str));
+               (void)strncpy(hdrptr, "  %CPU   %USR   %SYS   ", sizeof(str));
                hdrptr += 23;
                for (i = 0; i < pid_max_digits - 5; i++, hdrptr++)
                        *hdrptr = ' ';
-               strncpy(hdrptr, "PID S  CPU    Time Task",
+               (void)strncpy(hdrptr, "PID S  CPU    Time Task",
                        sizeof(str) - (3 + pid_max_digits));
                hdrptr += 23;
        }
@@ -1065,15 +1078,15 @@
                struct tm tm;
 
                get_tm(time_now, &tm);
-               strncpy(ptr, "  (", 3);
+               (void)strncpy(ptr, "  (", 3);
                ptr += 3;
-               ptr += putint(ptr, 2, tm.tm_hour, false);
+               ptr += putint(ptr, 2, tm.tm_hour, true);
                *ptr = ':';
                ptr++;
-               ptr += putint(ptr, 2, tm.tm_min, false);
+               ptr += putint(ptr, 2, tm.tm_min, true);
                *ptr = ':';
                ptr++;
-               ptr += putint(ptr, 2, tm.tm_sec, false);
+               ptr += putint(ptr, 2, tm.tm_sec, true);
                *ptr = ')';
                ptr++;
        }
@@ -1090,8 +1103,8 @@
        const uint64_t sticks,
        const uint64_t total_ticks,
        const cpu_info_t *info,
-       double *u_total,
-       double *s_total)
+       double *const u_total,
+       double *const s_total)
 {
        char buffer[512], *ptr = buffer;
 
@@ -1104,11 +1117,11 @@
        *u_total += cpu_u_usage;
        *s_total += cpu_s_usage;
 
-       ptr += putdouble(ptr, cpu_u_usage + cpu_s_usage);
+       ptr += putdouble(ptr, cpu_u_usage + cpu_s_usage, 100);
        *(ptr++) = ' ';
-       ptr += putdouble(ptr, cpu_u_usage);
+       ptr += putdouble(ptr, cpu_u_usage, 100);
        *(ptr++) = ' ';
-       ptr += putdouble(ptr, cpu_s_usage);
+       ptr += putdouble(ptr, cpu_s_usage, 100);
        *(ptr++) = ' ';
        ptr += putint(ptr, pid_max_digits, info->pid, false);
        *(ptr++) = ' ';
@@ -1139,11 +1152,11 @@
        if (UNLIKELY(opt_flags & OPT_TOTAL)) {
                char buffer[256], *ptr = buffer;
 
-               ptr += putdouble(ptr, u_total + s_total);
+               ptr += putdouble(ptr, u_total + s_total, 100);
                *(ptr++) = ' ';
-               ptr += putdouble(ptr, u_total);
+               ptr += putdouble(ptr, u_total, 100);
                *(ptr++) = ' ';
-               ptr += putdouble(ptr, s_total);
+               ptr += putdouble(ptr, s_total, 100);
                *(ptr++) = ' ';
                ptr += putstr(ptr, 5, "Total");
                df.df_putstrnl(buffer, ptr - buffer);
@@ -1171,7 +1184,7 @@
 
        if (UNLIKELY((sorted_cpu_infos =
             calloc(cpu_info_list_length, sizeof(*sorted_cpu_infos))) == NULL)) 
{
-               fprintf(stderr,
+               (void)fprintf(stderr,
                        "Cannot allocate buffer for sorting cpu_infos\n");
                exit(EXIT_FAILURE);
        }
@@ -1188,7 +1201,7 @@
        if (opt_flags & OPT_GRAND_TOTAL) {
                double cpu_u_total = 0.0, cpu_s_total = 0.0;
 
-               printf("Grand Total (from %" PRIu32 " samples, %.1f 
seconds):\n",
+               (void)printf("Grand Total (from %" PRIu32 " samples, %.1f 
seconds):\n",
                        samples, duration);
                info_banner_dump(time_now);
                for (i = 0; i < n; i++) {
@@ -1198,7 +1211,7 @@
                                &cpu_u_total, &cpu_s_total);
                }
                info_total_dump(cpu_u_total, cpu_s_total);
-               putchar('\n');
+               (void)putchar('\n');
        }
 
        if (!filename) {
@@ -1207,31 +1220,31 @@
        }
 
        if ((fp = fopen(filename, "w")) == NULL) {
-               fprintf(stderr, "Cannot write to file %s\n", filename);
+               (void)fprintf(stderr, "Cannot write to file %s\n", filename);
                free(sorted_cpu_infos);
                return;
        }
-       fprintf(fp, "Task:%s", (opt_flags & OPT_TIMESTAMP) ? "," : "");
+       (void)fprintf(fp, "Task:%s", (opt_flags & OPT_TIMESTAMP) ? "," : "");
        for (i = 0; i < n; i++)
-               fprintf(fp, ",%s (%d)", sorted_cpu_infos[i]->comm,
+               (void)fprintf(fp, ",%s (%d)", sorted_cpu_infos[i]->comm,
                        sorted_cpu_infos[i]->pid);
-       fprintf(fp, "\n");
+       (void)fprintf(fp, "\n");
 
-       fprintf(fp, "Ticks:%s", (opt_flags & OPT_TIMESTAMP) ? "," : "");
+       (void)fprintf(fp, "Ticks:%s", (opt_flags & OPT_TIMESTAMP) ? "," : "");
        for (i = 0; i < n; i++)
-               fprintf(fp, ",%" PRIu64, sorted_cpu_infos[i]->total);
-       fprintf(fp, "\n");
+               (void)fprintf(fp, ",%" PRIu64, sorted_cpu_infos[i]->total);
+       (void)fprintf(fp, "\n");
 
        for (sdl = sample_delta_list_head; sdl; sdl = sdl->next) {
                if (first_time < 0)
                        first_time = sdl->whence;
 
-               fprintf(fp, "%f", duration_round(sdl->whence - first_time));
+               (void)fprintf(fp, "%f", duration_round(sdl->whence - 
first_time));
                if (opt_flags & OPT_TIMESTAMP) {
                        struct tm tm;
 
                        get_tm(sdl->whence, &tm);
-                       fprintf(fp, ",%2.2d:%2.2d:%2.2d",
+                       (void)fprintf(fp, ",%02d:%02d:%02d",
                                tm.tm_hour, tm.tm_min, tm.tm_sec);
                }
 
@@ -1242,14 +1255,14 @@
                        if (sdi) {
                                double tmp_duration =
                                        duration_round(sdi->time_delta);
-                               fprintf(fp,",%f",
+                               (void)fprintf(fp,",%f",
                                        (tmp_duration < 0.01) ? 0.0 :
                                        100.0 * (double)sdi->delta /
                                        (duration * (double)nr_ticks));
                        } else
-                               fprintf(fp,", ");
+                               (void)fprintf(fp,", ");
                }
-               fprintf(fp, "\n");
+               (void)fprintf(fp, "\n");
        }
 
        free(sorted_cpu_infos);
@@ -1286,13 +1299,13 @@
        uint64_t utotal[cpu_max], stotal[cpu_max];
 
        if (!total_ticks) {
-               printf("Cannot calculate distribution of CPU utilisation, "
+               (void)printf("Cannot calculate distribution of CPU utilisation, 
"
                        "(zero clock tick)\n");
                return;
        }
 
-       memset(utotal, 0, sizeof(utotal));
-       memset(stotal, 0, sizeof(stotal));
+       (void)memset(utotal, 0, sizeof(utotal));
+       (void)memset(stotal, 0, sizeof(stotal));
 
        for (cpu_info = cpu_info_list; cpu_info;
             cpu_info = cpu_info->list_next) {
@@ -1300,10 +1313,10 @@
                utotal[cpu] += cpu_info->utotal;
                stotal[cpu] += cpu_info->stotal;
        }
-       printf("Distribution of CPU utilisation (per CPU):\n");
-       printf(" CPU#   USR%%   SYS%%\n");
+       (void)printf("Distribution of CPU utilisation (per CPU):\n");
+       (void)printf(" CPU#   USR%%   SYS%%\n");
        for (i = 0; i < cpu_max; i++)
-               printf("%5d %6.2f %6.2f\n",
+               (void)printf("%5d %6.2f %6.2f\n",
                        i,
                        100.0 * (double)utotal[i] / (double)total_ticks,
                        100.0 * (double)stotal[i] / (double)total_ticks);
@@ -1321,7 +1334,7 @@
        double min = DBL_MAX, max = -DBL_MAX, division, prev;
        const double scale = 100.0 / (double)nr_ticks;
 
-       memset(bucket, 0, sizeof(bucket));
+       (void)memset(bucket, 0, sizeof(bucket));
 
        for (sdl = sample_delta_list_head; sdl; sdl = sdl->next) {
                sample_delta_item_t *sdi;
@@ -1337,12 +1350,12 @@
        }
 
        if (valid <= 1) {
-               printf("Too few samples, cannot compute distribution\n");
+               (void)printf("Too few samples, cannot compute distribution\n");
                return;
        }
 
        if (max - min < 0.01) {
-               printf("Range is too small, cannot compute distribution\n");
+               (void)printf("Range is too small, cannot compute 
distribution\n");
                return;
        }
        division = ((max * 1.000001) - min) / (MAX_DIVISIONS);
@@ -1360,10 +1373,10 @@
                                max_bucket = bucket[v];
                }
        }
-       printf("Distribution of CPU utilisation (per Task):\n");
-       printf("%% CPU Utilisation   Count   (%%)\n");
+       (void)printf("Distribution of CPU utilisation (per Task):\n");
+       (void)printf("%% CPU Utilisation   Count   (%%)\n");
        for (prev = min, i = 0; i < MAX_DIVISIONS; i++, prev += division) {
-               printf("%6.2f - %6.2f  %8u %6.2f\n",
+               (void)printf("%6.2f - %6.2f  %8u %6.2f\n",
                        prev, prev + division - 0.001,
                        bucket[i],
                        100.0 * (double)bucket[i] / (double)total);
@@ -1390,16 +1403,16 @@
        }
 
        if (UNLIKELY((info = malloc(sizeof(*info))) == NULL)) {
-               fprintf(stderr, "Cannot allocate CPU info\n");
+               (void)fprintf(stderr, "Cannot allocate CPU info\n");
                exit(EXIT_FAILURE);
        }
-       memcpy(info, new_info, sizeof(*info));
+       (void)memcpy(info, new_info, sizeof(*info));
 
        if ((new_info->cmdline == NULL) || (opt_flags & OPT_CMD_COMM)) {
                info->cmdline = info->comm;
        } else {
                if (UNLIKELY((info->cmdline = strdup(new_info->cmdline)) == 
NULL)) {
-                       fprintf(stderr, "Cannot allocate CPU cmdline field 
info\n");
+                       (void)fprintf(stderr, "Cannot allocate CPU cmdline 
field info\n");
                        exit(EXIT_FAILURE);
                }
        }
@@ -1534,7 +1547,7 @@
                cpu_stat_free_list = cs_new->next;
        } else {
                if (UNLIKELY((cs_new = malloc(sizeof(*cs_new))) == NULL)) {
-                       fprintf(stderr,
+                       (void)fprintf(stderr,
                                "Out of memory allocating a cpu stat\n");
                        exit(1);
                }
@@ -1677,12 +1690,12 @@
  *  get_proc_stat()
  *     read /proc/stat
  */
-static int get_proc_stat(proc_stat_t *proc_stat)
+static int get_proc_stat(proc_stat_t * const proc_stat)
 {
        FILE *fp;
        char buffer[4096];
 
-       memset(proc_stat, 0, sizeof(*proc_stat));
+       (void)memset(proc_stat, 0, sizeof(*proc_stat));
 
        fp = fopen("/proc/stat", "r");
        if (UNLIKELY(!fp))
@@ -1721,7 +1734,7 @@
 static inline void proc_stat_diff(
        const proc_stat_t *old,
        const proc_stat_t *new,
-       proc_stat_t *delta)
+       proc_stat_t *const delta)
 {
        delta->ctxt = new->ctxt - old->ctxt;
        delta->irq = new->irq - old->irq;
@@ -1774,7 +1787,7 @@
                my_pid = getpid();
 
        if (UNLIKELY((dir = opendir("/proc")) == NULL)) {
-               fprintf(stderr, "Cannot read directory /proc\n");
+               (void)fprintf(stderr, "Cannot read directory /proc\n");
                return;
        }
        while ((entry = readdir(dir)) != NULL) {
@@ -1793,7 +1806,7 @@
                fnptr = filename;
                fnptr += putstr(fnptr, 6, "/proc/");
                fnptr += putstr(fnptr, PATH_MAX - 6, entry->d_name);
-               putstr(fnptr, 5, "/stat");
+               (void)putstr(fnptr, 5, "/stat");
                if ((fd = open(filename, O_RDONLY)) < 0)
                        continue;
 
@@ -1888,7 +1901,7 @@
  *  cpu_freq_average()
  *     get average CPU frequency
  */
-static double cpu_freq_average(uint32_t max_cpus)
+static double cpu_freq_average(const uint32_t max_cpus)
 {
        size_t i, n = 0;
        double total_freq = 0;
@@ -1900,7 +1913,7 @@
                fnptr = filename;
                fnptr += putstr(fnptr, 28, "/sys/devices/system/cpu/cpu");
                fnptr += putuint(fnptr, i);
-               putstr(fnptr, 25, "/cpufreq/scaling_cur_freq");
+               (void)putstr(fnptr, 25, "/cpufreq/scaling_cur_freq");
 
                if (LIKELY((fd = open(filename, O_RDONLY)) > -1)) {
                        char buffer[64];
@@ -1926,7 +1939,7 @@
  *  cpu_freq_format()
  *     scale cpu freq into a human readable form
  */
-static char *cpu_freq_format(double freq)
+static char *cpu_freq_format(const double freq)
 {
        static char buffer[40];
        char *suffix = "EHz", *ptr = buffer;
@@ -1997,7 +2010,7 @@
                } else
                        goto unknown;
        }
-       snprintf(buffer, sizeof(buffer), "%" PRId32, cpus);
+       (void)snprintf(buffer, sizeof(buffer), "%" PRId32, cpus);
 
        return buffer;
 unknown:
@@ -2072,7 +2085,7 @@
  */
 static void show_usage(void)
 {
-       printf(APP_NAME ", version " VERSION "\n\n"
+       (void)printf(APP_NAME ", version " VERSION "\n\n"
                "Usage: " APP_NAME " [options] [duration] [count]\n"
                " -h help\n"
                " -a calculate CPU utilisation based on all the CPU ticks\n"
@@ -2149,11 +2162,11 @@
                        errno = 0;
                        n_lines = (int32_t)strtol(optarg, NULL, 10);
                        if (errno) {
-                               fprintf(stderr, "Invalid value for -n 
option\n");
+                               (void)fprintf(stderr, "Invalid value for -n 
option\n");
                                exit(EXIT_FAILURE);
                        }
                        if (n_lines < 1) {
-                               fprintf(stderr,
+                               (void)fprintf(stderr,
                                        "-n option must be greater than 0\n");
                                exit(EXIT_FAILURE);
                        }
@@ -2162,7 +2175,7 @@
                        errno = 0;
                        opt_pid = strtol(optarg, NULL, 10);
                        if (errno) {
-                               fprintf(stderr,
+                               (void)fprintf(stderr,
                                        "Invalid value for -o option\n");
                                exit(EXIT_FAILURE);
                        }
@@ -2177,7 +2190,7 @@
                case 't':
                        opt_threshold = atof(optarg);
                        if (opt_threshold < 0.0) {
-                               fprintf(stderr,
+                               (void)fprintf(stderr,
                                        "-t threshold must be 0 or more.\n");
                                exit(EXIT_FAILURE);
                        }
@@ -2205,13 +2218,13 @@
        }
 
        if (count_bits(opt_flags & OPT_CMD_ALL) > 1) {
-               fprintf(stderr, "Cannot have -c, -l, -s at same time.\n");
+               (void)fprintf(stderr, "Cannot have -c, -l, -s at same time.\n");
                exit(EXIT_FAILURE);
        }
        if (optind < argc) {
                duration_secs = atof(argv[optind++]);
                if (duration_secs < 0.333) {
-                       fprintf(stderr, "Duration must 0.333 or more\n");
+                       (void)fprintf(stderr, "Duration must 0.333 or more\n");
                        exit(EXIT_FAILURE);
                }
        }
@@ -2220,11 +2233,11 @@
                errno = 0;
                count = (int64_t)strtoll(argv[optind++], NULL, 10);
                if (errno) {
-                       fprintf(stderr, "Invalid value for count\n");
+                       (void)fprintf(stderr, "Invalid value for count\n");
                        exit(EXIT_FAILURE);
                }
                if (count < 1) {
-                       fprintf(stderr, "Count must be greater than 0\n");
+                       (void)fprintf(stderr, "Count must be greater than 0\n");
                        exit(EXIT_FAILURE);
                }
        }
@@ -2232,22 +2245,22 @@
 
        pid_max_digits = get_pid_max_digits();
 
-       memset(&new_action, 0, sizeof(new_action));
+       (void)memset(&new_action, 0, sizeof(new_action));
        for (i = 0; signals[i] != -1; i++) {
                new_action.sa_handler = handle_sig;
-               sigemptyset(&new_action.sa_mask);
+               (void)sigemptyset(&new_action.sa_mask);
                new_action.sa_flags = 0;
 
                if (sigaction(signals[i], &new_action, NULL) < 0) {
-                       fprintf(stderr, "sigaction failed: errno=%d (%s)\n",
+                       (void)fprintf(stderr, "sigaction failed: errno=%d 
(%s)\n",
                                errno, strerror(errno));
                        exit(EXIT_FAILURE);
                }
        }
-       memset(&new_action, 0, sizeof(new_action));
+       (void)memset(&new_action, 0, sizeof(new_action));
        new_action.sa_handler = handle_sigwinch;
        if (sigaction(SIGWINCH, &new_action , NULL) < 0) {
-               fprintf(stderr, "sigaction failed: errno=%d (%s)\n",
+               (void)fprintf(stderr, "sigaction failed: errno=%d (%s)\n",
                        errno, strerror(errno));
                exit(EXIT_FAILURE);
        }
@@ -2256,7 +2269,7 @@
        cpu_stats_new = calloc(TABLE_SIZE, sizeof(*cpu_stats_new));
 
        if (UNLIKELY(cpu_stats_old == NULL || cpu_stats_new == NULL)) {
-               fprintf(stderr, "Cannot allocate CPU statistics tables\n");
+               (void)fprintf(stderr, "Cannot allocate CPU statistics 
tables\n");
                exit(EXIT_FAILURE);
        }
        proc_stat_old = &proc_stats[0];
@@ -2308,7 +2321,7 @@
                                                goto retry;
                                }
                        } else {
-                               fprintf(stderr,
+                               (void)fprintf(stderr,
                                        "select failed: errno=%d (%s)\n",
                                        errno, strerror(errno));
                                break;


Reply via email to