When getopt() is passed an option string like "-m -n" and the
parameter m is defined as "m:", getopt returns a special error
to indication that the optstring started with a "-". Any getopt()
caller that is just catching the "?" error character will not
not catch this special error, so it silently eats the parameter
following -m.
Lots of getopt loops in xfsprogs have this issue. Convert them all
to just use a "default:" to catch anything unexpected.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
case 'V':
printf(_("%s version %s\n"), progname, VERSION);
exit(0);
- case '?':
+ default:
usage();
}
}
case 's':
summaryflag = 1;
break;
- case '?':
+ default:
return usage();
}
}
case 'V':
printf(_("%s version %s\n"), progname, VERSION);
exit(0);
- case '?':
+ default:
usage();
- /*NOTREACHED*/
}
}
- if (optind + 1 != argc) {
+ if (optind + 1 != argc)
usage();
- /*NOTREACHED*/
- }
fsdevice = argv[optind];
if (!x.disfile)
case 'V':
printf(_("%s version %s\n"), progname, VERSION);
exit(0);
- case '?':
default:
usage();
}
/* Expect no src_path arg */
src_path_arg = 0;
break;
+ default:
+ return command_usage(©_range_cmd);
}
}
case 'V':
printf(_("%s version %s\n"), progname, VERSION);
exit(0);
- case '?':
+ default:
usage();
}
}
case 'V':
printf(_("%s version %s\n"), progname, VERSION);
exit(0);
- case '?':
+ default:
unknown(optopt, "");
}
}
case 'e':
report_corrected = true;
break;
- case '?':
+ default:
usage();
}
}
case 'x':
scrub_data = true;
break;
- case '?':
- /* fall through */
default:
usage();
}
case 's':
summaryflag = 1;
break;
- case '?':
default:
return command_usage(&freesp_cmd);
}
eofb.eof_min_file_size = cvtnum(fsgeom->blocksize,
fsgeom->sectsize, optarg);
break;
- case '?':
default:
return command_usage(&prealloc_cmd);
}