Richard W.M. Jones
2010-May-12 18:04 UTC
[Libguestfs] [PATCH] fish: Fix guestfish -N option when called with unknown image type.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw -------------- next part -------------->From d723a7c618cf764638e6da07e3b3abd72de30cb4 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Wed, 12 May 2010 19:01:29 +0100 Subject: [PATCH] fish: Fix guestfish -N option when called with unknown image type. Previously it was falling off the end of the loop if you called it with an unknown image type. --- fish/prep.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fish/prep.c b/fish/prep.c index 6fd1d6b..6fe4ba9 100644 --- a/fish/prep.c +++ b/fish/prep.c @@ -104,6 +104,8 @@ static const struct prep preps[] = { }, }; +#define nr_preps (sizeof preps / sizeof preps[0]) + void list_prepared_drives (void) { @@ -111,7 +113,7 @@ list_prepared_drives (void) printf (_("List of available prepared disk images:\n\n")); - for (i = 0; i < sizeof preps / sizeof preps[0]; ++i) { + for (i = 0; i < nr_preps; ++i) { printf (_("\ guestfish -N %-16s %s\n\ \n\ @@ -169,11 +171,11 @@ parse_type_string (const char *type_string) /* Match on the type part (without parameters). */ size_t len = strcspn (type_string, ":"); - for (i = 0; i < sizeof preps / sizeof preps[0]; ++i) + for (i = 0; i < nr_preps; ++i) if (STRCASEEQLEN (type_string, preps[i].name, len)) break; - if (preps[i].name == NULL) { + if (i == nr_preps) { fprintf (stderr, _("\ guestfish: -N parameter '%s': no such prepared disk image known.\n\ Use 'guestfish -N list' to list possible values for the -N parameter.\n"), -- 1.6.6.1
Matthew Booth
2010-May-13 14:29 UTC
[Libguestfs] [PATCH] fish: Fix guestfish -N option when called with unknown image type.
On 12/05/10 19:04, Richard W.M. Jones wrote:>>From d723a7c618cf764638e6da07e3b3abd72de30cb4 Mon Sep 17 00:00:00 2001 > From: Richard Jones <rjones at redhat.com> > Date: Wed, 12 May 2010 19:01:29 +0100 > Subject: [PATCH] fish: Fix guestfish -N option when called with unknown image type. > > Previously it was falling off the end of the loop if you > called it with an unknown image type. > --- > fish/prep.c | 8 +++++--- > 1 files changed, 5 insertions(+), 3 deletions(-)ACK. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490