Eliminated optarg global being used outside of the function which called getopt

MFC after:	2 weeks
This commit is contained in:
Steven Hartland 2014-04-24 01:12:52 +00:00
parent 5b245b8ae0
commit d9dab6e243

View File

@ -495,9 +495,8 @@ usage(boolean_t requested)
} }
static int static int
parseprop(nvlist_t *props) parseprop(nvlist_t *props, char *propname)
{ {
char *propname = optarg;
char *propval, *strval; char *propval, *strval;
if ((propval = strchr(propname, '=')) == NULL) { if ((propval = strchr(propname, '=')) == NULL) {
@ -526,7 +525,7 @@ parse_depth(char *opt, int *flags)
depth = (int)strtol(opt, &tmp, 0); depth = (int)strtol(opt, &tmp, 0);
if (*tmp) { if (*tmp) {
(void) fprintf(stderr, (void) fprintf(stderr,
gettext("%s is not an integer\n"), optarg); gettext("%s is not an integer\n"), opt);
usage(B_FALSE); usage(B_FALSE);
} }
if (depth < 0) { if (depth < 0) {
@ -617,7 +616,7 @@ zfs_do_clone(int argc, char **argv)
while ((c = getopt(argc, argv, "o:p")) != -1) { while ((c = getopt(argc, argv, "o:p")) != -1) {
switch (c) { switch (c) {
case 'o': case 'o':
if (parseprop(props)) if (parseprop(props, optarg))
return (1); return (1);
break; break;
case 'p': case 'p':
@ -767,7 +766,7 @@ zfs_do_create(int argc, char **argv)
nomem(); nomem();
break; break;
case 'o': case 'o':
if (parseprop(props)) if (parseprop(props, optarg))
goto error; goto error;
break; break;
case 's': case 's':
@ -3636,7 +3635,7 @@ zfs_do_snapshot(int argc, char **argv)
while ((c = getopt(argc, argv, "ro:")) != -1) { while ((c = getopt(argc, argv, "ro:")) != -1) {
switch (c) { switch (c) {
case 'o': case 'o':
if (parseprop(props)) if (parseprop(props, optarg))
return (1); return (1);
break; break;
case 'r': case 'r':