diff options
author | Richard Jones <rjones@redhat.com> | 2010-05-12 19:01:29 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-05-13 16:22:10 +0100 |
commit | 520d895383c6e2b3eff1c4e3761624ebbb5f8b09 (patch) | |
tree | b2d90d4e82ec9be7ddebe6c8f053b0b210b71084 | |
parent | 94e310dcfbcd368cbe02dbc1643ed2ff9821cd48 (diff) | |
download | libguestfs-520d895383c6e2b3eff1c4e3761624ebbb5f8b09.tar.gz libguestfs-520d895383c6e2b3eff1c4e3761624ebbb5f8b09.tar.xz libguestfs-520d895383c6e2b3eff1c4e3761624ebbb5f8b09.zip |
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.
-rw-r--r-- | fish/prep.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fish/prep.c b/fish/prep.c index 6fd1d6b1..6fe4ba97 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"), |