[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/2] Replace 'int' with 'size_t' passim.



From: "Richard W.M. Jones" <rjones redhat com>

Analyze all uses of 'int' in the code, and replace with 'size_t' where
appropriate.
---
 daemon/augeas.c               |    2 +-
 daemon/checksum.c             |    2 +-
 daemon/daemon.h               |    2 +-
 daemon/debug.c                |   68 ++++++++++++++++++++--------------------
 daemon/ext2.c                 |    6 ++--
 daemon/file.c                 |    5 ++-
 daemon/find.c                 |    9 +++--
 daemon/guestfsd.c             |   16 +++++----
 daemon/lvm.c                  |    5 ++-
 daemon/mount.c                |    3 +-
 daemon/proto.c                |    6 ++--
 daemon/readdir.c              |    2 +-
 daemon/xattr.c                |   14 ++++----
 fish/fish.c                   |   24 +++++++-------
 fish/fish.h                   |    2 +-
 fish/glob.c                   |    8 ++--
 fish/inspect.c                |    2 +-
 fish/progress.c               |    9 +++--
 fish/rc.c                     |    3 +-
 fish/tilde.c                  |    2 +-
 fuse/guestmount.c             |    2 +-
 generator/generator_java.ml   |    4 +-
 generator/generator_python.ml |    6 ++--
 inspector/virt-inspector.c    |    8 ++--
 ocaml/guestfs_c.c             |    4 +-
 src/proto.c                   |    2 +-
 26 files changed, 113 insertions(+), 103 deletions(-)

diff --git a/daemon/augeas.c b/daemon/augeas.c
index 4a09f57..f03b819 100644
--- a/daemon/augeas.c
+++ b/daemon/augeas.c
@@ -339,7 +339,7 @@ do_aug_ls (const char *path)
 {
   char **matches;
   char *buf;
-  int len;
+  size_t len;
 
   NEED_AUG (NULL);
 
diff --git a/daemon/checksum.c b/daemon/checksum.c
index 684f83f..be460f8 100644
--- a/daemon/checksum.c
+++ b/daemon/checksum.c
@@ -58,7 +58,7 @@ checksum (const char *csumtype, int fd)
   const char *program;
   char *out, *err;
   int flags, r;
-  int len;
+  size_t len;
 
   program = program_of_csum (csumtype);
   if (program == NULL) {
diff --git a/daemon/daemon.h b/daemon/daemon.h
index b973a7f..f3e77da 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -191,7 +191,7 @@ extern int cancel_receive (void);
  * reply, then send_file_* for each FileOut parameter.
  * Note max write size if GUESTFS_MAX_CHUNK_SIZE.
  */
-extern int send_file_write (const void *buf, int len);
+extern int send_file_write (const void *buf, size_t len);
 extern int send_file_end (int cancel);
 
 /* only call this if there is a FileOut parameter */
diff --git a/daemon/debug.c b/daemon/debug.c
index 4036af6..4e8d662 100644
--- a/daemon/debug.c
+++ b/daemon/debug.c
@@ -47,21 +47,21 @@
 
 struct cmd {
   const char *cmd;
-  char * (*f) (const char *subcmd, int argc, char *const *const argv);
+  char * (*f) (const char *subcmd, size_t argc, char *const *const argv);
 };
 
-static char *debug_help (const char *subcmd, int argc, char *const *const argv);
-static char *debug_binaries (const char *subcmd, int argc, char *const *const argv);
-static char *debug_core_pattern (const char *subcmd, int argc, char *const *const argv);
-static char *debug_env (const char *subcmd, int argc, char *const *const argv);
-static char *debug_fds (const char *subcmd, int argc, char *const *const argv);
-static char *debug_ldd (const char *subcmd, int argc, char *const *const argv);
-static char *debug_ls (const char *subcmd, int argc, char *const *const argv);
-static char *debug_ll (const char *subcmd, int argc, char *const *const argv);
-static char *debug_progress (const char *subcmd, int argc, char *const *const argv);
-static char *debug_qtrace (const char *subcmd, int argc, char *const *const argv);
-static char *debug_segv (const char *subcmd, int argc, char *const *const argv);
-static char *debug_sh (const char *subcmd, int argc, char *const *const argv);
+static char *debug_help (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_binaries (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_core_pattern (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_env (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_fds (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_ldd (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_ls (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_ll (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_progress (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_qtrace (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_segv (const char *subcmd, size_t argc, char *const *const argv);
+static char *debug_sh (const char *subcmd, size_t argc, char *const *const argv);
 
 static struct cmd cmds[] = {
   { "help", debug_help },
@@ -82,7 +82,7 @@ static struct cmd cmds[] = {
 char *
 do_debug (const char *subcmd, char *const *argv)
 {
-  int argc, i;
+  size_t argc, i;
 
   for (i = argc = 0; argv[i] != NULL; ++i)
     argc++;
@@ -97,9 +97,9 @@ do_debug (const char *subcmd, char *const *argv)
 }
 
 static char *
-debug_help (const char *subcmd, int argc, char *const *const argv)
+debug_help (const char *subcmd, size_t argc, char *const *const argv)
 {
-  int len, i;
+  size_t len, i;
   char *r, *p;
 
   r = strdup ("Commands supported:");
@@ -128,7 +128,7 @@ debug_help (const char *subcmd, int argc, char *const *const argv)
 
 /* Show open FDs. */
 static char *
-debug_fds (const char *subcmd, int argc, char *const *const argv)
+debug_fds (const char *subcmd, size_t argc, char *const *const argv)
 {
   int r;
   char *out;
@@ -196,7 +196,7 @@ debug_fds (const char *subcmd, int argc, char *const *const argv)
 
 /* Force a segfault in the daemon. */
 static char *
-debug_segv (const char *subcmd, int argc, char *const *const argv)
+debug_segv (const char *subcmd, size_t argc, char *const *const argv)
 {
   /* http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html
    * "Dereferencing a NULL Pointer: contrary to popular belief,
@@ -214,16 +214,16 @@ debug_segv (const char *subcmd, int argc, char *const *const argv)
  * because it's not using the guest shell, and is not chrooted.
  */
 static char *
-debug_sh (const char *subcmd, int argc, char *const *const argv)
+debug_sh (const char *subcmd, size_t argc, char *const *const argv)
 {
+  char *cmd;
+  size_t len, i, j;
+
   if (argc < 1) {
     reply_with_error ("sh: expecting a command to run");
     return NULL;
   }
 
-  char *cmd;
-  int len, i, j;
-
   /* guestfish splits the parameter(s) into a list of strings,
    * and we have to reassemble them here.  Not ideal. XXX
    */
@@ -268,7 +268,7 @@ debug_sh (const char *subcmd, int argc, char *const *const argv)
 
 /* Print the environment that commands get (by running external printenv). */
 static char *
-debug_env (const char *subcmd, int argc, char *const *const argv)
+debug_env (const char *subcmd, size_t argc, char *const *const argv)
 {
   int r;
   char *out, *err;
@@ -290,7 +290,7 @@ debug_env (const char *subcmd, int argc, char *const *const argv)
  * See tests/regressions/rhbz727178.sh
  */
 static char *
-debug_binaries (const char *subcmd, int argc, char *const *const argv)
+debug_binaries (const char *subcmd, size_t argc, char *const *const argv)
 {
   int r;
   char *out, *err;
@@ -318,7 +318,7 @@ debug_binaries (const char *subcmd, int argc, char *const *const argv)
  * See tests/regressions/rhbz727178.sh
  */
 static char *
-debug_ldd (const char *subcmd, int argc, char *const *const argv)
+debug_ldd (const char *subcmd, size_t argc, char *const *const argv)
 {
   int r;
   char *out, *err, *ret;
@@ -359,11 +359,11 @@ debug_ldd (const char *subcmd, int argc, char *const *const argv)
 
 /* List files in the appliance. */
 static char *
-debug_ls (const char *subcmd, int argc, char *const *const argv)
+debug_ls (const char *subcmd, size_t argc, char *const *const argv)
 {
-  int len = count_strings (argv);
+  size_t len = count_strings (argv);
   const char *cargv[len+3];
-  int i;
+  size_t i;
 
   cargv[0] = "ls";
   cargv[1] = "-a";
@@ -389,11 +389,11 @@ debug_ls (const char *subcmd, int argc, char *const *const argv)
 
 /* List files in the appliance. */
 static char *
-debug_ll (const char *subcmd, int argc, char *const *const argv)
+debug_ll (const char *subcmd, size_t argc, char *const *const argv)
 {
-  int len = count_strings (argv);
+  size_t len = count_strings (argv);
   const char *cargv[len+3];
-  int i;
+  size_t i;
 
   cargv[0] = "ls";
   cargv[1] = "-la";
@@ -419,7 +419,7 @@ debug_ll (const char *subcmd, int argc, char *const *const argv)
 
 /* Generate progress notification messages in order to test progress bars. */
 static char *
-debug_progress (const char *subcmd, int argc, char *const *const argv)
+debug_progress (const char *subcmd, size_t argc, char *const *const argv)
 {
   if (argc < 1) {
   error:
@@ -455,7 +455,7 @@ debug_progress (const char *subcmd, int argc, char *const *const argv)
  * crashes doesn't chroot.
  */
 static char *
-debug_core_pattern (const char *subcmd, int argc, char *const *const argv)
+debug_core_pattern (const char *subcmd, size_t argc, char *const *const argv)
 {
   if (argc < 1) {
     reply_with_error ("core_pattern: expecting a core pattern");
@@ -510,7 +510,7 @@ write_cb (void *fd_ptr, const void *buf, size_t len)
  * directory in the libguestfs source tree.
  */
 static char *
-debug_qtrace (const char *subcmd, int argc, char *const *const argv)
+debug_qtrace (const char *subcmd, size_t argc, char *const *const argv)
 {
   int enable;
 
diff --git a/daemon/ext2.c b/daemon/ext2.c
index 5defbc8..99d4574 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -463,7 +463,7 @@ do_mke2fs_J (const char *fstype, int blocksize, const char *device,
   char blocksize_s[32];
   snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize);
 
-  int len = strlen (journal);
+  size_t len = strlen (journal);
   char jdev[len+32];
   snprintf (jdev, len+32, "device=%s", journal);
 
@@ -500,7 +500,7 @@ do_mke2fs_JL (const char *fstype, int blocksize, const char *device,
   char blocksize_s[32];
   snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize);
 
-  int len = strlen (label);
+  size_t len = strlen (label);
   char jdev[len+32];
   snprintf (jdev, len+32, "device=LABEL=%s", label);
 
@@ -531,7 +531,7 @@ do_mke2fs_JU (const char *fstype, int blocksize, const char *device,
   char blocksize_s[32];
   snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize);
 
-  int len = strlen (uuid);
+  size_t len = strlen (uuid);
   char jdev[len+32];
   snprintf (jdev, len+32, "device=UUID=%s", uuid);
 
diff --git a/daemon/file.c b/daemon/file.c
index 161ea31..ef7b50c 100644
--- a/daemon/file.c
+++ b/daemon/file.c
@@ -89,7 +89,8 @@ char *
 do_cat (const char *path)
 {
   int fd;
-  int alloc, size, r, max;
+  size_t alloc, size, max;
+  ssize_t r;
   char *buf, *buf2;
 
   CHROOT_IN;
@@ -671,7 +672,7 @@ do_file (const char *path)
 char *
 do_zfile (const char *method, const char *path)
 {
-  int len;
+  size_t len;
   const char *zcat;
   char *cmd;
   FILE *fp;
diff --git a/daemon/find.c b/daemon/find.c
index 014712e..833a391 100644
--- a/daemon/find.c
+++ b/daemon/find.c
@@ -31,9 +31,10 @@
 #include "actions.h"
 
 static int
-input_to_nul (FILE *fp, char *buf, int maxlen)
+input_to_nul (FILE *fp, char *buf, size_t maxlen)
 {
-  int i = 0, c;
+  size_t i = 0;
+  int c;
 
   while (i < maxlen) {
     c = fgetc (fp);
@@ -52,7 +53,9 @@ char **
 do_find (const char *dir)
 {
   struct stat statbuf;
-  int r, len, sysrootdirlen;
+  int r;
+  size_t sysrootdirlen;
+  size_t len;
   char *cmd;
   FILE *fp;
   DECLARE_STRINGSBUF (ret);
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 6174074..43f41df 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -364,7 +364,7 @@ char *
 sysroot_path (const char *path)
 {
   char *r;
-  int len = strlen (path) + sysroot_len + 1;
+  size_t len = strlen (path) + sysroot_len + 1;
 
   r = malloc (len);
   if (r == NULL)
@@ -497,7 +497,7 @@ sort_strings (char **argv, size_t len)
 void
 free_strings (char **argv)
 {
-  int argc;
+  size_t argc;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     free (argv[argc]);
@@ -523,7 +523,8 @@ commandf (char **stdoutput, char **stderror, int flags, const char *name, ...)
   va_list args;
   const char **argv;
   char *s;
-  int i, r;
+  size_t i;
+  int r;
 
   /* Collect the command line arguments into an array. */
   i = 2;
@@ -655,7 +656,7 @@ int
 commandrvf (char **stdoutput, char **stderror, int flags,
             char const* const *argv)
 {
-  int so_size = 0, se_size = 0;
+  size_t so_size = 0, se_size = 0;
   int so_fd[2], se_fd[2];
   int flag_copy_stdin = flags & COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN;
   int stdin_fd[2] = { -1, -1 };
@@ -894,9 +895,10 @@ commandrvf (char **stdoutput, char **stderror, int flags,
     *stderror = q;
     if (*stderror) {
       (*stderror)[se_size] = '\0';
-      se_size--;
-      while (se_size >= 0 && (*stderror)[se_size] == '\n')
-        (*stderror)[se_size--] = '\0';
+      while (se_size > 0 && (*stderror)[se_size-1] == '\n') {
+        se_size--;
+        (*stderror)[se_size] = '\0';
+      }
     }
   }
 
diff --git a/daemon/lvm.c b/daemon/lvm.c
index 8b56921..7519756 100644
--- a/daemon/lvm.c
+++ b/daemon/lvm.c
@@ -45,8 +45,8 @@ static char **
 convert_lvm_output (char *out, const char *prefix)
 {
   char *p, *pend;
-  int len;
   DECLARE_STRINGSBUF (ret);
+  size_t len;
   char buf[256];
   char *str;
 
@@ -317,7 +317,8 @@ int
 do_lvm_remove_all (void)
 {
   char **xs;
-  int i, r;
+  size_t i;
+  int r;
   char *err;
 
   /* Remove LVs. */
diff --git a/daemon/mount.c b/daemon/mount.c
index 5e74ce8..293353d 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -327,7 +327,8 @@ do_umount_all (void)
   struct mntent *m;
   DECLARE_STRINGSBUF (mounts);
   char *err;
-  int i, r;
+  size_t i;
+  int r;
 
   /* NB: Eventually we should aim to parse /proc/self/mountinfo, but
    * that requires custom parsing code.
diff --git a/daemon/proto.c b/daemon/proto.c
index ac62a6b..4bbe8f8 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -71,7 +71,7 @@ static struct timeval start_t;
 static struct timeval last_progress_t;
 
 /* Counts the number of progress notifications sent during this call. */
-static int count_progress;
+static size_t count_progress;
 
 /* The daemon communications socket. */
 static int sock;
@@ -477,13 +477,13 @@ static int send_chunk (const guestfs_chunk *);
 
 /* Also check if the library sends us a cancellation message. */
 int
-send_file_write (const void *buf, int len)
+send_file_write (const void *buf, size_t len)
 {
   guestfs_chunk chunk;
   int cancel;
 
   if (len > GUESTFS_MAX_CHUNK_SIZE) {
-    fprintf (stderr, "guestfsd: send_file_write: len (%d) > GUESTFS_MAX_CHUNK_SIZE (%d)\n",
+    fprintf (stderr, "guestfsd: send_file_write: len (%zu) > GUESTFS_MAX_CHUNK_SIZE (%d)\n",
              len, GUESTFS_MAX_CHUNK_SIZE);
     return -1;
   }
diff --git a/daemon/readdir.c b/daemon/readdir.c
index b8f5fea..f0ddd21 100644
--- a/daemon/readdir.c
+++ b/daemon/readdir.c
@@ -34,7 +34,7 @@ do_readdir (const char *path)
   guestfs_int_dirent v;
   DIR *dir;
   struct dirent *d;
-  int i;
+  size_t i;
 
   ret = malloc (sizeof *ret);
   if (ret == NULL) {
diff --git a/daemon/xattr.c b/daemon/xattr.c
index 92d0cf1..ca1b722 100644
--- a/daemon/xattr.c
+++ b/daemon/xattr.c
@@ -120,7 +120,7 @@ getxattrs (const char *path,
 {
   ssize_t len, vlen;
   char *buf = NULL;
-  int i, j;
+  size_t i, j;
   guestfs_int_xattr_list *r = NULL;
 
   CHROOT_IN;
@@ -155,7 +155,7 @@ getxattrs (const char *path,
    * len.  First count the strings.
    */
   r->guestfs_int_xattr_list_len = 0;
-  for (i = 0; i < len; i += strlen (&buf[i]) + 1)
+  for (i = 0; i < (size_t) len; i += strlen (&buf[i]) + 1)
     r->guestfs_int_xattr_list_len++;
 
   r->guestfs_int_xattr_list_val =
@@ -165,7 +165,7 @@ getxattrs (const char *path,
     goto error;
   }
 
-  for (i = 0, j = 0; i < len; i += strlen (&buf[i]) + 1, ++j) {
+  for (i = 0, j = 0; i < (size_t) len; i += strlen (&buf[i]) + 1, ++j) {
     CHROOT_IN;
     vlen = getxattr (path, &buf[i], NULL, 0);
     CHROOT_OUT;
@@ -203,7 +203,7 @@ getxattrs (const char *path,
   free (buf);
   if (r) {
     if (r->guestfs_int_xattr_list_val) {
-      unsigned int k;
+      size_t k;
       for (k = 0; k < r->guestfs_int_xattr_list_len; ++k) {
         free (r->guestfs_int_xattr_list_val[k].attrname);
         free (r->guestfs_int_xattr_list_val[k].attrval.attrval_val);
@@ -260,7 +260,7 @@ do_lxattrlist (const char *path, char *const *names)
   char pathname[PATH_MAX];
   size_t path_len = strlen (path);
   guestfs_int_xattr_list *ret = NULL;
-  int i, j;
+  size_t i, j;
   size_t k, m, nr_attrs;
   ssize_t len, vlen;
   char *buf = NULL;
@@ -339,7 +339,7 @@ do_lxattrlist (const char *path, char *const *names)
      * len.  First count the strings.
      */
     nr_attrs = 0;
-    for (i = 0; i < len; i += strlen (&buf[i]) + 1)
+    for (i = 0; i < (size_t) len; i += strlen (&buf[i]) + 1)
       nr_attrs++;
 
     newptr =
@@ -363,7 +363,7 @@ do_lxattrlist (const char *path, char *const *names)
       entry[m].attrval.attrval_val = NULL;
     }
 
-    for (i = 0, j = 0; i < len; i += strlen (&buf[i]) + 1, ++j) {
+    for (i = 0, j = 0; i < (size_t) len; i += strlen (&buf[i]) + 1, ++j) {
       CHROOT_IN;
       vlen = lgetxattr (pathname, &buf[i], NULL, 0);
       CHROOT_OUT;
diff --git a/fish/fish.c b/fish/fish.c
index 8e3e9fb..8bfea32 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -60,9 +60,9 @@ static int launch (void);
 static void interactive (void);
 static void shell_script (void);
 static void script (int prompt);
-static void cmdline (char *argv[], int optind, int argc);
+static void cmdline (char *argv[], size_t optind, size_t argc);
 static struct parsed_command parse_command_line (char *buf, int *exit_on_error_rtn);
-static int parse_quoted_string (char *p);
+static ssize_t parse_quoted_string (char *p);
 static int execute_and_inline (const char *cmd, int exit_on_error);
 static void error_cb (guestfs_h *g, void *data, const char *msg);
 static void initialize_readline (void);
@@ -624,7 +624,7 @@ rl_gets (int prompt)
 #endif /* HAVE_LIBREADLINE */
 
   static char buf[8192];
-  int len;
+  size_t len;
 
   if (prompt) printf (FISH);
   line_read = fgets (buf, sizeof buf, stdin);
@@ -701,7 +701,7 @@ parse_command_line (char *buf, int *exit_on_error_rtn)
 {
   struct parsed_command pcmd;
   char *p, *pend;
-  int len;
+  ssize_t len;
   int tilde_candidate;
   int r;
   const size_t argv_len = sizeof pcmd.argv / sizeof pcmd.argv[0];
@@ -880,7 +880,7 @@ hexdigit (char d)
  * with the true character.  Since the string is returned in place,
  * the escapes must make the string shorter.
  */
-static int
+static ssize_t
 parse_quoted_string (char *p)
 {
   char *start = p;
@@ -991,7 +991,7 @@ execute_and_inline (const char *cmd, int global_exit_on_error)
 }
 
 static void
-cmdline (char *argv[], int optind, int argc)
+cmdline (char *argv[], size_t optind, size_t argc)
 {
   const char *cmd;
   char **params;
@@ -1040,7 +1040,7 @@ int
 issue_command (const char *cmd, char *argv[], const char *pipecmd,
                int rc_exit_on_error_flag)
 {
-  int argc;
+  size_t argc;
   int stdout_saved_fd = -1;
   int pid = 0;
   int r;
@@ -1208,17 +1208,17 @@ error_cb (guestfs_h *g, void *data, const char *msg)
 void
 free_strings (char **argv)
 {
-  int argc;
+  size_t argc;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     free (argv[argc]);
   free (argv);
 }
 
-int
+size_t
 count_strings (char *const *argv)
 {
-  int c;
+  size_t c;
 
   for (c = 0; argv[c]; ++c)
     ;
@@ -1228,7 +1228,7 @@ count_strings (char *const *argv)
 void
 print_strings (char *const *argv)
 {
-  int argc;
+  size_t argc;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     printf ("%s\n", argv[argc]);
@@ -1237,7 +1237,7 @@ print_strings (char *const *argv)
 void
 print_table (char *const *argv)
 {
-  int i;
+  size_t i;
 
   for (i = 0; argv[i] != NULL; i += 2)
     printf ("%s: %s\n", argv[i], argv[i+1]);
diff --git a/fish/fish.h b/fish/fish.h
index 668202d..b4b05fe 100644
--- a/fish/fish.h
+++ b/fish/fish.h
@@ -69,7 +69,7 @@ extern int issue_command (const char *cmd, char *argv[], const char *pipe, int r
 extern void list_builtin_commands (void);
 extern int display_builtin_command (const char *cmd);
 extern void free_strings (char **argv);
-extern int count_strings (char *const *argv);
+extern size_t count_strings (char *const *argv);
 extern void print_strings (char *const *argv);
 extern void print_table (char *const *argv);
 extern int is_true (const char *str);
diff --git a/fish/glob.c b/fish/glob.c
index 0141040..108eda3 100644
--- a/fish/glob.c
+++ b/fish/glob.c
@@ -28,7 +28,7 @@
 /* A bit tricky because in the case where there are multiple
  * paths we have to perform a Cartesian product.
  */
-static void glob_issue (char *cmd, size_t argc, char ***globs, int *posn, int *count, int *r);
+static void glob_issue (char *cmd, size_t argc, char ***globs, size_t *posn, size_t *count, int *r);
 
 int
 run_glob (const char *cmd, size_t argc, char *argv[])
@@ -44,8 +44,8 @@ run_glob (const char *cmd, size_t argc, char *argv[])
    * argv[1-].
    */
   char **globs[argc];
-  int posn[argc];
-  int count[argc];
+  size_t posn[argc];
+  size_t count[argc];
   size_t i;
   int r = 0;
 
@@ -131,7 +131,7 @@ run_glob (const char *cmd, size_t argc, char *argv[])
 
 static void
 glob_issue (char *cmd, size_t argc,
-            char ***globs, int *posn, int *count,
+            char ***globs, size_t *posn, size_t *count,
             int *r)
 {
   size_t i;
diff --git a/fish/inspect.c b/fish/inspect.c
index f93367b..3358cd4 100644
--- a/fish/inspect.c
+++ b/fish/inspect.c
@@ -36,7 +36,7 @@ static char *root = NULL;
 static void
 free_strings (char **argv)
 {
-  int argc;
+  size_t argc;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     free (argv[argc]);
diff --git a/fish/progress.c b/fish/progress.c
index 6c30e95..c296f40 100644
--- a/fish/progress.c
+++ b/fish/progress.c
@@ -88,7 +88,7 @@ rmsd_get_standard_deviation (const struct rmsd *r)
 
 struct progress_bar {
   double start;         /* start time of command */
-  int count;            /* number of progress notifications per cmd */
+  size_t count;         /* number of progress notifications per cmd */
   struct rmsd rmsd;     /* running mean and standard deviation */
   int have_terminfo;
   int utf8_mode;
@@ -154,7 +154,7 @@ progress_bar_reset (struct progress_bar *bar)
 }
 
 static const char *
-spinner (struct progress_bar *bar, int count)
+spinner (struct progress_bar *bar, size_t count)
 {
   /* Choice of unicode spinners.
    *
@@ -262,7 +262,8 @@ void
 progress_bar_set (struct progress_bar *bar,
                   uint64_t position, uint64_t total)
 {
-  int i, cols, pulse_mode;
+  size_t i, cols;
+  int pulse_mode;
   double ratio;
   const char *s_open, *s_dot, *s_dash, *s_close;
 
@@ -307,7 +308,7 @@ progress_bar_set (struct progress_bar *bar,
     fputs (s_open, stdout);
 
     if (!pulse_mode) {
-      int dots = ratio * (double) (cols - COLS_OVERHEAD);
+      size_t dots = ratio * (double) (cols - COLS_OVERHEAD);
 
       for (i = 0; i < dots; ++i)
         fputs (s_dot, stdout);
diff --git a/fish/rc.c b/fish/rc.c
index 4c119f7..52a2623 100644
--- a/fish/rc.c
+++ b/fish/rc.c
@@ -36,7 +36,8 @@
 #include "rc_protocol.h"
 
 static void
-create_sockpath (pid_t pid, char *sockpath, int len, struct sockaddr_un *addr)
+create_sockpath (pid_t pid, char *sockpath, size_t len,
+                 struct sockaddr_un *addr)
 {
   char dir[128];
   uid_t euid = geteuid ();
diff --git a/fish/tilde.c b/fish/tilde.c
index 8ee1437..9267966 100644
--- a/fish/tilde.c
+++ b/fish/tilde.c
@@ -78,7 +78,7 @@ static char *
 expand_home (char *orig, const char *append)
 {
   const char *home;
-  int len;
+  size_t len;
   char *str;
 
   home = getenv ("HOME");
diff --git a/fuse/guestmount.c b/fuse/guestmount.c
index a9bf4e3..f6c3463 100644
--- a/fuse/guestmount.c
+++ b/fuse/guestmount.c
@@ -990,7 +990,7 @@ main (int argc, char *argv[])
   int option_index;
   struct sigaction sa;
 
-  int fuse_argc = 0;
+  size_t fuse_argc = 0;
   const char **fuse_argv = NULL;
 
 #define ADD_FUSE_ARG(str)                                               \
diff --git a/generator/generator_java.ml b/generator/generator_java.ml
index 3a13052..d95bd59 100644
--- a/generator/generator_java.ml
+++ b/generator/generator_java.ml
@@ -683,7 +683,7 @@ and generate_java_struct_return typ jtyp cols =
         pr "  }\n";
     | name, FBuffer ->
         pr "  {\n";
-        pr "    int len = r->%s_len;\n" name;
+        pr "    size_t len = r->%s_len;\n" name;
         pr "    char s[len+1];\n";
         pr "    memcpy (s, r->%s, len);\n" name;
         pr "    s[len] = 0;\n";
@@ -726,7 +726,7 @@ and generate_java_struct_list_return typ jtyp cols =
         pr "    }\n";
     | name, FBuffer ->
         pr "    {\n";
-        pr "      int len = r->val[i].%s_len;\n" name;
+        pr "      size_t len = r->val[i].%s_len;\n" name;
         pr "      char s[len+1];\n";
         pr "      memcpy (s, r->val[i].%s, len);\n" name;
         pr "      s[len] = 0;\n";
diff --git a/generator/generator_python.ml b/generator/generator_python.ml
index 7d8513a..fbf3151 100644
--- a/generator/generator_python.ml
+++ b/generator/generator_python.ml
@@ -89,7 +89,7 @@ static PyObject *
 put_string_list (char * const * const argv)
 {
   PyObject *list;
-  int argc, i;
+  size_t argc, i;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     ;
@@ -110,7 +110,7 @@ static PyObject *
 put_table (char * const * const argv)
 {
   PyObject *list, *item;
-  int argc, i;
+  size_t argc, i;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     ;
@@ -134,7 +134,7 @@ put_table (char * const * const argv)
 static void
 free_strings (char **argv)
 {
-  int argc;
+  size_t argc;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     free (argv[argc]);
diff --git a/inspector/virt-inspector.c b/inspector/virt-inspector.c
index 269e51d..103a61e 100644
--- a/inspector/virt-inspector.c
+++ b/inspector/virt-inspector.c
@@ -62,7 +62,7 @@ static void output_drive_mappings (xmlTextWriterPtr xo, char *root);
 static void output_applications (xmlTextWriterPtr xo, char *root);
 static void canonicalize (char *dev);
 static void free_strings (char **argv);
-static int count_strings (char *const*argv);
+static size_t count_strings (char *const*argv);
 static void do_xpath (const char *query);
 
 static inline char *
@@ -790,17 +790,17 @@ canonicalize (char *dev)
 static void
 free_strings (char **argv)
 {
-  int argc;
+  size_t argc;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     free (argv[argc]);
   free (argv);
 }
 
-static int
+static size_t
 count_strings (char *const *argv)
 {
-  int c;
+  size_t c;
 
   for (c = 0; argv[c]; ++c)
     ;
diff --git a/ocaml/guestfs_c.c b/ocaml/guestfs_c.c
index c4b2a96..cfbe1cc 100644
--- a/ocaml/guestfs_c.c
+++ b/ocaml/guestfs_c.c
@@ -190,7 +190,7 @@ ocaml_guestfs_strings_val (guestfs_h *g, value sv)
 {
   CAMLparam1 (sv);
   char **r;
-  unsigned int i;
+  size_t i;
 
   r = guestfs_safe_malloc (g, sizeof (char *) * (Wosize_val (sv) + 1));
   for (i = 0; i < Wosize_val (sv); ++i)
@@ -204,7 +204,7 @@ ocaml_guestfs_strings_val (guestfs_h *g, value sv)
 void
 ocaml_guestfs_free_strings (char **argv)
 {
-  unsigned int i;
+  size_t i;
 
   for (i = 0; argv[i] != NULL; ++i)
     free (argv[i]);
diff --git a/src/proto.c b/src/proto.c
index 1ab8d18..c9ddaca 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -241,7 +241,7 @@ static int
 read_log_message_or_eof (guestfs_h *g, int fd, int error_if_eof)
 {
   char buf[BUFSIZ];
-  int n;
+  ssize_t n;
 
 #if 0
   debug (g, "read_log_message_or_eof: %p g->state = %d, fd = %d",
-- 
1.7.9.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]