Previously it was falling off the end of the loop if you
called it with an unknown image type.
+#define nr_preps (sizeof preps / sizeof preps[0])
+
void
list_prepared_drives (void)
{
void
list_prepared_drives (void)
{
printf (_("List of available prepared disk images:\n\n"));
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\
printf (_("\
guestfish -N %-16s %s\n\
\n\
/* Match on the type part (without parameters). */
size_t len = strcspn (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 (STRCASEEQLEN (type_string, preps[i].name, len))
break;
- if (preps[i].name == NULL) {
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"),
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"),