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

[Libguestfs] [PATCH] daemon: count_strings function returns size_t



The return value from count_strings can only ever be >= 0, so it
should be a size_t not an int.

This is in preparation for fixing 598309, but I'm still testing that
(rather large) patch.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
>From dd409a0e719aa8e33b5825fcd3e0799ea287e1d2 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones redhat com>
Date: Wed, 2 Jun 2010 12:31:40 +0100
Subject: [PATCH] daemon: count_strings function returns size_t

---
 daemon/daemon.h   |    2 +-
 daemon/guestfsd.c |    4 ++--
 daemon/parted.c   |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/daemon/daemon.h b/daemon/daemon.h
index de598cd..d90b65c 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -43,7 +43,7 @@ extern int xread (int sock, void *buf, size_t len)
   __attribute__((__warn_unused_result__));
 
 extern int add_string (char ***argv, int *size, int *alloc, const char *str);
-extern int count_strings (char *const *argv);
+extern size_t count_strings (char *const *argv);
 extern void sort_strings (char **argv, int len);
 extern void free_strings (char **argv);
 extern void free_stringslen (char **argv, int len);
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index c0d524a..f9e5a68 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -544,10 +544,10 @@ add_string (char ***argv, int *size, int *alloc, const char *str)
   return 0;
 }
 
-int
+size_t
 count_strings (char *const *argv)
 {
-  int argc;
+  size_t argc;
 
   for (argc = 0; argv[argc] != NULL; ++argc)
     ;
diff --git a/daemon/parted.c b/daemon/parted.c
index 9c65570..bf45f8b 100644
--- a/daemon/parted.c
+++ b/daemon/parted.c
@@ -392,7 +392,7 @@ do_part_get_bootable (const char *device, int partnum)
     return -1;
 
   /* We want lines[1+partnum]. */
-  if (count_strings (lines) < 1+partnum) {
+  if (count_strings (lines) < (size_t) (1+partnum)) {
     reply_with_error ("partition number out of range: %d", partnum);
     free_strings (lines);
     return -1;
-- 
1.6.6.1


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