Package: memstat
Version: 0.4.0.0.1
Severity: minor

The attached patch attempts to correct some variable types mismatches.
There's one more type mismatch in there, which needs a bit of thought:

  memstat.c: In function `scan_directory':
  memstat/memstat.c:161: warning: passing arg 1 of `register_path' with
                                  different width due to prototype

as it implies a modification to the `mapping' structure. `unsigned int
fs' needs to be the same type (__dev_t) as stat.st_dev. The
`register_path' function needs to be modified. I used the following
compiler options:

  -Wall -Wshadow -O2 -g -W -Wformat-security -Wformat=2 -Wpointer-arith
  -Wbad-function-cast -Wstrict-prototypes -Winline -Wconversion
  -Wmissing-prototypes -Wimplicit -Wunused -Wcomment -Wchar-subscripts
  -Wcast-qual -Wcast-align -Wwrite-strings -O -Wuninitialized -Wfloat-equal
  -Wunreachable-code


Cheers,
Cristian

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (99, 'testing'), (49, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.15
Locale: LANG=en_US, LC_CTYPE= (charmap=ISO-8859-1)

Versions of packages memstat depends on:
ii  libc6                       2.3.2.ds1-22 GNU C Library: Shared libraries an

-- no debconf information
--- memstat/memstat.c   8 Mar 2006 12:08:24 -0000       1.2
+++ memstat/memstat.c   8 Mar 2006 12:40:23 -0000
@@ -30,12 +30,12 @@ struct mapping
 };
 
 mapping maptab_data;
-int     maptab_fill;
-int     maptab_size;
+size_t  maptab_fill;
+size_t  maptab_size;
 
-void maptab_expand()
+static void maptab_expand(void)
 {
-  int bytes;
+  size_t bytes;
   maptab_size = maptab_size*2 + 100;
   bytes = maptab_size * sizeof(struct mapping);
   maptab_data = (mapping)realloc(maptab_data, bytes);
@@ -45,7 +45,7 @@ void maptab_expand()
   }
 }
 
-dev_t convert_to_dev_t(char *str)
+static dev_t convert_to_dev_t(char *str)
 {
   unsigned int result = 0;
   while (*str) {
@@ -57,7 +57,7 @@ dev_t convert_to_dev_t(char *str)
   return result;
 }
 
-void read_proc()
+static void read_proc(void)
 {
   unsigned int nread, pid, lo, hi, offs; unsigned long inode; char *p;
   char dev[80], buff[PATH_MAX + 300], *path;
@@ -107,7 +107,7 @@ void read_proc()
   closedir(d);
 }
 
-int sort_by_pid(mapping m1, mapping m2)
+static int sort_by_pid(mapping m1, mapping m2)
 {
   int delta;
   delta = m1->pid - m2->pid;
@@ -122,7 +122,7 @@ int sort_by_pid(mapping m1, mapping m2)
   return delta;
 }
 
-int sort_by_inode(mapping m1, mapping m2)
+static int sort_by_inode(mapping m1, mapping m2)
 {
   int delta;
   delta = m1->fs - m2->fs;
@@ -133,9 +133,10 @@ int sort_by_inode(mapping m1, mapping m2
   return delta;
 }
 
-void register_path(unsigned int fs, unsigned int inode, char *path, int valid)
+static void register_path(unsigned int fs, unsigned int inode, char *path, int 
valid)
 {
-  int i; mapping m; char *copy=0;
+  size_t i;
+  mapping m; char *copy=0;
   for (i=0; i<maptab_fill; i++) {
     m = maptab_data + i;
     if ((m->path)&&(m->path[0]=='[')&&(m->fs == fs)&&(m->inode == inode)) {
@@ -146,7 +147,7 @@ void register_path(unsigned int fs, unsi
   }
 }
 
-void scan_directory(char *dir)
+static void scan_directory(char *dir)
 {
   DIR *d; struct dirent *ent;
   struct stat info; int ok;
@@ -162,7 +163,7 @@ void scan_directory(char *dir)
   closedir(d);
 }
 
-void scan_fpath(char *fn)
+static void scan_fpath(const char *fn)
 {
   char *p;
   FILE *f = fopen(fn, "r");
@@ -180,7 +181,7 @@ void scan_fpath(char *fn)
   fclose(f);
 }
 
-void printline(char *str)
+static void printline(char *str)
 {
   int len;
   if (wide) goto done;
@@ -194,7 +195,7 @@ done:
   printf("%s\n", str);
 }
 
-void summarize_usage()
+static void summarize_usage(void)
 {
   char buffer[8192];
   unsigned int grand, i, offs, fs, inode, pid, lo, hi, scan, tail, total;
@@ -245,7 +246,7 @@ void summarize_usage()
   printf("%7dk\n", grand/1024);
 }
 
-void usage(char *prog)
+static void usage(char *prog)
 {
   fprintf(stderr,"usage: %s [-w]\n", prog);
   exit(1);

Reply via email to