Richard W.M. Jones
2010-Jun-02 13:17 UTC
[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 -------------- next part -------------->From dd409a0e719aa8e33b5825fcd3e0799ea287e1d2 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at 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
Apparently Analagous Threads
- Re: [PATCH v4 1/2] New API: btrfs_balance_status
- [PATCH v7 13/13] daemon: Link guestfsd with libutils.
- [PATCH] daemon/Win32: use gnulib modules connect, socket and symlinkat (for readlinkat).
- [PATCH 0/6] Simple fixes for cross-compiling the daemon
- [PATCH 1/4] daemon: introduce free_stringsbuf