]> granicus.if.org Git - procps-ng/commitdiff
gcc 3.0 warnings
authoralbert <>
Sat, 12 Oct 2002 04:25:57 +0000 (04:25 +0000)
committeralbert <>
Sat, 12 Oct 2002 04:25:57 +0000 (04:25 +0000)
18 files changed:
Makefile
pgrep.c
proc/devname.c
proc/ksym.c
proc/output.c
proc/procps.h
proc/readproc.c
proc/sig.c
proc/sysinfo.c
ps/common.h
ps/display.c
ps/global.c
ps/output.c
ps/parser.c
ps/sortformat.c
top.c
vmstat.c
w.c

index 30073f4eb5e6f7d068143b804ed5cbceb547fa53..66c7f76166cca47791928937de53253b1d8d9c22 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -157,7 +157,7 @@ watch: % : %.o
 ############ progX --> progY
 
 snice kill: skill
-       ln skill $@
+       ln -f skill $@
 
 pkill: pgrep
-       ln pgrep pkill
+       ln -f pgrep pkill
diff --git a/pgrep.c b/pgrep.c
index 9b3ad2f8022f1986f341085f1d36861847b031ae..36ecc9afd3c121b1123e0d3b90f9bb280a22f0cf 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -28,7 +28,7 @@
 #include "proc/version.h" /* procps_version */
 
 static int i_am_pkill = 0;
-char *progname = "pgrep";
+static const char *progname = "pgrep";
 
 union el {
        long    num;
@@ -44,7 +44,7 @@ static int opt_negate = 0;
 static int opt_exact = 0;
 static int opt_signal = SIGTERM;
 
-static char *opt_delim = "\n";
+static const char *opt_delim = "\n";
 static union el *opt_pgrp = NULL;
 static union el *opt_gid = NULL;
 static union el *opt_ppid = NULL;
index f41fde20ea4121f5e992279a1b06eedb3083ba87..10c297c6791f67591c7f197145eb1f0a69fd06d5 100644 (file)
@@ -175,7 +175,7 @@ static int guess_name(char * const buf, int maj, int min){
  * Useful names could be in /proc/PID/fd/2 (stderr, seldom redirected)
  * and in /proc/PID/fd/255 (used by bash to remember the tty).
  */
-static int link_name(char * const buf, int maj, int min, int pid, char *name){
+static int link_name(char * const buf, int maj, int min, int pid, const char *name){
   struct stat sbuf;
   char path[32];
   int count;
index dfa20178228fa3287d46302f9968f0add8a52331..4951b71cf96ec9ff0765bdb5c8d371119fc50b20 100644 (file)
@@ -112,7 +112,7 @@ static const char dash[] = "-";
 
 /* These mostly rely on POSIX to make them zero. */
 
-static const symb hashtable[256];
+static symb hashtable[256];
 
 static char       *sysmap_data;
 static unsigned    sysmap_room;
@@ -123,7 +123,7 @@ static char       *ksyms_data;
 static unsigned    ksyms_room     = 4096;
 static symb       *ksyms_index;
 static unsigned    ksyms_count;
-static int         idx_room;
+static unsigned    idx_room;
 
 /*********************************/
 
index 76ae26163f56ee53bcab90b970e412257aa4add2..56243e1fb0aae405ca6720f0397254d80ab2e6a4 100644 (file)
@@ -29,8 +29,8 @@ unsigned print_str(FILE* file, char *s, unsigned max) {
    to octal as we go, separating items of the list by 'sep' and stopping after
    processing max chars of output (accounting for expansion due to octal rep).
 */
-unsigned print_strlist(FILE* file, char **strs, char* sep, unsigned max) {
-    int i, n, seplen = strlen(sep);
+unsigned print_strlist(FILE* file, char **strs, unsigned max) {
+    int i, n;
     for (n=0; *strs && n < max; strs++) {
        for (i=0; strs[0][i] && n+i < max; i++)
            if (isprint(strs[0][i]) || strs[0][i] == ' ')
@@ -43,9 +43,9 @@ unsigned print_strlist(FILE* file, char **strs, char* sep, unsigned max) {
                    return max - n;
            }
        n += i;
-       if (n + seplen < max) {
-           fputs(sep, file);
-           n += seplen;
+       if (n + 1 < max) {
+           fputc(' ', file);
+           n++;
        } else
            return max - n;
     }
index bd9c664588376e6e8aa21c630807e70e4df01c93..0b1503c985335fcc5a7b6a9052740a85da3733be 100644 (file)
@@ -23,4 +23,4 @@ extern int   open_psdb(const char *override);
 extern int   open_psdb_message(const char *override, void (*message)(const char *, ...));
 
 extern unsigned print_str    (FILE* file, char *s, unsigned max);
-extern unsigned print_strlist(FILE* file, char **strs, char* sep, unsigned max);
+extern unsigned print_strlist(FILE* file, char **strs, unsigned max);
index be7b8b24a424736eb7a34482a2b699e5161ffbd8..2bc7bc87ed884f6fbe8a5a04b7986b37d1c4fe33 100644 (file)
@@ -211,7 +211,7 @@ static void statm2proc(char* s, proc_t* P) {
 /*    fprintf(stderr, "statm2proc converted %d fields.\n",num); */
 }
 
-static int file2str(char *directory, char *what, char *ret, int cap) {
+static int file2str(const char *directory, const char *what, char *ret, int cap) {
     static char filename[80];
     int fd, num_read;
 
@@ -223,7 +223,7 @@ static int file2str(char *directory, char *what, char *ret, int cap) {
     return num_read;
 }
 
-static char** file2strvec(char* directory, char* what) {
+static char** file2strvec(const char* directory, const char* what) {
     char buf[2048];    /* read buf bytes at a time */
     char *p, *rbuf = 0, *endbuf, **q, **ret;
     int fd, tot = 0, n, c, end_of_file = 0;
index d2c543ef475332cf23fe0992df55a1292a8f2932..85ec8ef0c9be8c6f541d7dc5ca02259510516e66 100644 (file)
 #endif
 
 typedef struct mapstruct {
-  char *name;
+  const char *name;
   int num;
 } mapstruct;
 
 
-static mapstruct sigtable[] = {
+static const mapstruct sigtable[] = {
   {"ABRT",   SIGABRT},  /* IOT */
   {"ALRM",   SIGALRM},
   {"BUS",    SIGBUS},
@@ -98,7 +98,7 @@ static mapstruct sigtable[] = {
 static const int number_of_signals = sizeof(sigtable)/sizeof(mapstruct);
 
 static int compare_signal_names(const void *a, const void *b){
-  return strcasecmp( ((mapstruct*)a)->name, ((mapstruct*)b)->name );
+  return strcasecmp( ((const mapstruct*)a)->name, ((const mapstruct*)b)->name );
 }
 
 /* return -1 on failure */
index 5a686f018c6d07904bdbb465e612a09294a68261..36e4040dd498f64c337949b1104afb9367103ce6 100644 (file)
@@ -281,11 +281,11 @@ void loadavg(double *av1, double *av5, double *av15) {
 
 typedef struct mem_table_struct {
   const char *name;     /* memory type name */
-  const unsigned *slot; /* slot in return struct */
+  unsigned *slot; /* slot in return struct */
 } mem_table_struct;
 
 static int compare_mem_table_structs(const void *a, const void *b){
-  return strcmp(((mem_table_struct*)a)->name,((mem_table_struct*)b)->name);
+  return strcmp(((const mem_table_struct*)a)->name,((const mem_table_struct*)b)->name);
 }
 
 /* example data, following junk, with comments added:
@@ -342,7 +342,6 @@ unsigned kb_main_used;
 unsigned kb_writeback;
 unsigned kb_slab;
 unsigned nr_reversemaps;
-unsigned kb_active;
 unsigned kb_committed_as;
 unsigned kb_dirty;
 unsigned kb_inactive;
@@ -385,7 +384,7 @@ void meminfo(void){
 
   FILE_TO_BUF(MEMINFO_FILE,meminfo_fd);
 
-  kb_inactive = -1;
+  kb_inactive = ~0U;
 
   head = buf;
   for(;;){
@@ -412,7 +411,7 @@ nextline:
     kb_low_total = kb_main_total;
     kb_low_free  = kb_main_free;
   }
-  if(kb_inactive==-1){
+  if(kb_inactive==~0U){
     kb_inactive = kb_inact_dirty + kb_inact_clean;
   }
   kb_swap_used = kb_swap_total - kb_swap_free;
@@ -425,11 +424,11 @@ nextline:
 
 typedef struct vm_table_struct {
   const char *name;     /* VM statistic name */
-  const unsigned *slot; /* slot in return struct */
+  unsigned *slot;       /* slot in return struct */
 } vm_table_struct;
 
 static int compare_vm_table_structs(const void *a, const void *b){
-  return strcmp(((vm_table_struct*)a)->name,((vm_table_struct*)b)->name);
+  return strcmp(((const vm_table_struct*)a)->name,((const vm_table_struct*)b)->name);
 }
 
 unsigned vm_nr_dirty;
index cb431d53ec844158bcef66517b427799b4a457a0..52524f9a75537d754b5020633a4d248551e27c29 100644 (file)
@@ -244,11 +244,11 @@ extern void reset_global(void);
 
 /* global.c */
 extern int             all_processes;
-extern char           *bsd_j_format;
-extern char           *bsd_l_format;
-extern char           *bsd_s_format;
-extern char           *bsd_u_format;
-extern char           *bsd_v_format;
+extern const char     *bsd_j_format;
+extern const char     *bsd_l_format;
+extern const char     *bsd_s_format;
+extern const char     *bsd_u_format;
+extern const char     *bsd_v_format;
 extern int             bsd_c_option;
 extern int             bsd_e_option;
 extern uid_t           cached_euid;
@@ -274,10 +274,10 @@ extern unsigned long   seconds_since_boot;
 extern selection_node *selection_list;
 extern unsigned        simple_select;
 extern sort_node      *sort_list;
-extern char           *sysv_f_format;
-extern char           *sysv_fl_format;
-extern char           *sysv_j_format;
-extern char           *sysv_l_format;
+extern const char     *sysv_f_format;
+extern const char     *sysv_fl_format;
+extern const char     *sysv_j_format;
+extern const char     *sysv_l_format;
 extern int             unix_f_option;
 extern int             user_is_number;
 extern int             wchan_is_number;
index 0a2c2c0045a39b874c23b16e16bfd6796a21b31b..beca76ecba91b8e6d317cf2e1970131098a5d6e8 100644 (file)
@@ -288,7 +288,7 @@ static int compare_two_procs(const void *a, const void *b){
   sort_node *tmp_list = sort_list;
   while(tmp_list){
     int result;
-    result = (*tmp_list->sr)(*(const proc_t **)a, *(const proc_t **)b);
+    result = (*tmp_list->sr)(*(const proc_t *const*)a, *(const proc_t *const*)b);
     if(result) return (tmp_list->reverse) ? -result : result;
     tmp_list = tmp_list->next;
   }
index 240b46a160786ff0b28408f4f8667d853cd86c05..0769de2c20d5a107cc6601b413341412de320b25 100644 (file)
 #include <grp.h>
 #include <string.h>
 
-/*#undef __GLIBC_MINOR__
-#define __GLIBC_MINOR__ 1 */
 #include "common.h"
-/*#undef __GLIBC_MINOR__
-#define __GLIBC_MINOR__ 0 */
 
 #include <sys/sysmacros.h>
 #include "../proc/version.h"
 #endif
 
 
-static char *saved_personality_text = "You found a bug!";
+static const char * saved_personality_text = "You found a bug!";
 
 int             all_processes = -1;
-char           *bsd_j_format = (char *)0xdeadbeef;
-char           *bsd_l_format = (char *)0xdeadbeef;
-char           *bsd_s_format = (char *)0xdeadbeef;
-char           *bsd_u_format = (char *)0xdeadbeef;
-char           *bsd_v_format = (char *)0xdeadbeef;
+const char     *bsd_j_format = (const char *)0xdeadbeef;
+const char     *bsd_l_format = (const char *)0xdeadbeef;
+const char     *bsd_s_format = (const char *)0xdeadbeef;
+const char     *bsd_u_format = (const char *)0xdeadbeef;
+const char     *bsd_v_format = (const char *)0xdeadbeef;
 int             bsd_c_option = -1;
 int             bsd_e_option = -1;
 uid_t           cached_euid = -1;
@@ -71,10 +67,10 @@ unsigned long   seconds_since_boot = -1;
 selection_node *selection_list = (selection_node *)0xdeadbeef;
 unsigned        simple_select = 0xffffffff;
 sort_node      *sort_list = (sort_node *)0xdeadbeef; /* ready-to-use sort list */
-char           *sysv_f_format = (char *)0xdeadbeef;
-char           *sysv_fl_format = (char *)0xdeadbeef;
-char           *sysv_j_format = (char *)0xdeadbeef;
-char           *sysv_l_format = (char *)0xdeadbeef;
+const char     *sysv_f_format = (const char *)0xdeadbeef;
+const char     *sysv_fl_format = (const char *)0xdeadbeef;
+const char     *sysv_j_format = (const char *)0xdeadbeef;
+const char     *sysv_l_format = (const char *)0xdeadbeef;
 int             unix_f_option = -1;
 int             user_is_number = -1;
 int             wchan_is_number = -1;
@@ -142,11 +138,11 @@ typedef struct personality_table_struct {
 } personality_table_struct;
 
 static int compare_personality_table_structs(const void *a, const void *b){
-  return strcasecmp(((personality_table_struct*)a)->name,((personality_table_struct*)b)->name);
+  return strcasecmp(((const personality_table_struct*)a)->name,((const personality_table_struct*)b)->name);
 }
 
 static const char *set_personality(void){
-  char *s;
+  const char *s;
   size_t sl;
   char buf[16];
   personality_table_struct findme = { buf, NULL};
index b4bbfe77e15d69915abfea92b07d27cad449b267..c85330fa8e9a77dd75ad62ee62f0643bf0bcdd2e 100644 (file)
@@ -833,7 +833,7 @@ static int pr_stime(void){
   struct tm *proc_time;
   struct tm *our_time;
   time_t t;
-  char *fmt;
+  const char *fmt;
   int tm_year;
   int tm_yday;
   our_time = localtime(&seconds_since_1970);   /* not reentrant */
@@ -1510,11 +1510,11 @@ void print_format_specifiers(void){
 /************ comparison functions for bsearch *************/
 
 static int compare_format_structs(const void *a, const void *b){
-  return strcmp(((format_struct*)a)->spec,((format_struct*)b)->spec);
+  return strcmp(((const format_struct*)a)->spec,((const format_struct*)b)->spec);
 }
 
 static int compare_macro_structs(const void *a, const void *b){
-  return strcmp(((macro_struct*)a)->spec,((macro_struct*)b)->spec);
+  return strcmp(((const macro_struct*)a)->spec,((const macro_struct*)b)->spec);
 }
 
 /******** look up structs as needed by the sort & format parsers ******/
index 84781df2ef0bf87d9e66feb505271e0d127b1997..645601869d41e99bfbb3e5db3b62c684c0223f41 100644 (file)
@@ -713,7 +713,7 @@ typedef struct gnu_table_struct {
 } gnu_table_struct;
 
 static int compare_gnu_table_structs(const void *a, const void *b){
-  return strcmp(((gnu_table_struct*)a)->name,((gnu_table_struct*)b)->name);
+  return strcmp(((const gnu_table_struct*)a)->name,((const gnu_table_struct*)b)->name);
 }
 
 /* Option arguments are after ':', after '=', or in argv[n+1] */
index fa8a34c28de6fe63ec97362021490cdca982bd97..52acbeae2948899c3ed2b425e2b1576399399b9e 100644 (file)
@@ -93,7 +93,7 @@ static format_node *do_one_spec(const char *spec, const char *override){
 static void O_wrap(sf_node *sfn, int otype){
   format_node *fnode;
   format_node *endp;
-  char *trailer;
+  const char *trailer;
 
   trailer = (otype=='b') ? "END_BSD" : "END_SYS5" ;
 
diff --git a/top.c b/top.c
index 4c27b16a58e5d2587cf0e9aa501c9949261ed6ab..722f6ba60da55d4b85a02f67ca13f1d087556bfe 100644 (file)
--- a/top.c
+++ b/top.c
@@ -287,7 +287,7 @@ static char *strim (int sp, char *str)
          * This guy just facilitates Batch and protects against dumb ttys
          * -- we'd 'inline' him but he's only called twice per frame,
          * yet used in many other locations. */
-static char *tg2 (int x, int y)
+static const char *tg2 (int x, int y)
 {
    return Cap_can_goto ? tgoto(cursor_address, x, y) : "";
 }
@@ -375,6 +375,7 @@ static void bye_bye (int eno, const char *str)
          *    SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT and SIGTERM */
 static void stop (int dont_care_sig)
 {
+   (void)dont_care_sig;
    bye_bye(0, NULL);
 }
 
@@ -405,6 +406,7 @@ static void std_err (const char *str)
          *    SIGTSTP, SIGTTIN and SIGTTOU */
 static void suspend (int dont_care_sig)
 {
+  (void)dont_care_sig;
       /* reset terminal */
    tcsetattr(STDIN_FILENO, TCSAFLUSH, &Savedtty);
    printf("%s%s", tg2(0, Screen_rows), Cap_curs_norm);
@@ -670,7 +672,7 @@ static int get_int (const char *prompt)
          *    SK_Kb (1) it's kilobytes
          *    SK_Mb (2) it's megabytes
          *    SK_Gb (3) it's gigabytes  */
-static char *scale_num (unsigned num, const int width, const unsigned type)
+static const char *scale_num (unsigned num, const int width, const unsigned type)
 {
       /* kilobytes, megabytes, gigabytes, duh! */
    static float scale[] = { 1024, 1024*1024, 1024*1024*1024, 0 };
@@ -706,7 +708,7 @@ static char *scale_num (unsigned num, const int width, const unsigned type)
         /*
          * Do some scaling stuff.
          * Format 'tics' to fit 'width' */
-static char *scale_tics (TICS_t tics, const int width)
+static const char *scale_tics (TICS_t tics, const int width)
 {
 #define T1 "%u:%02u.%02u"
 #define T2 "%u:%02u"
@@ -1587,6 +1589,7 @@ static void wins_reflag (int what, int flg)
          *    SIGWINCH and SIGCONT */
 static void wins_resize (int dont_care_sig)
 {
+   (void)dont_care_sig;
    struct winsize wz;
    WIN_t *w;
 
@@ -2653,6 +2656,7 @@ static void so_lets_see_em (void)
          */
 int main (int dont_care_argc, char **argv)
 {
+   (void)dont_care_argc;
    before(*argv);
   /*
    Ok, she's gone now.  Don't you mind her, she means well but yes, she is
index 23c93c78b51f3586cb637614feca039a8db05875..d0ddb3254945663d046d8e51d5b2fb2122da1bcd 100644 (file)
--- a/vmstat.c
+++ b/vmstat.c
@@ -57,7 +57,7 @@ static void usage(void) {
   exit(EXIT_FAILURE);
 }
 
-static void crash(char *filename) {
+static void crash(const char *filename) {
     perror(filename);
     exit(EXIT_FAILURE);
 }
diff --git a/w.c b/w.c
index ae38250cc4793df5662379bc77cbed73912eced7..e0f3322320bd33805c5376f56685378b31695e16 100644 (file)
--- a/w.c
+++ b/w.c
@@ -218,7 +218,7 @@ static void showinfo(utmp_t *u, int formtype, int maxcmd, int from) {
     fputs("  ", stdout);
     if (best) {
        if (best->cmdline)
-           print_strlist(stdout, best->cmdline, " ", maxcmd);
+           print_strlist(stdout, best->cmdline, maxcmd);
        else
            printf("%*.*s", -maxcmd, maxcmd, best->cmd);
     } else {