getparameter: avoid returning uninitialized 'usedarg'

Fixes #1728
This commit is contained in:
Daniel Stenberg 2017-08-04 11:49:27 +02:00
parent 0b11660234
commit d6c8def82a
2 changed files with 3 additions and 3 deletions

View File

@ -443,6 +443,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled bool toggle = TRUE; /* how to switch boolean options, on or off. Controlled
by using --OPTION or --no-OPTION */ by using --OPTION or --no-OPTION */
*usedarg = FALSE; /* default is that we don't use the arg */
if(('-' != flag[0]) || if(('-' != flag[0]) ||
(('-' == flag[0]) && ('-' == flag[1]))) { (('-' == flag[0]) && ('-' == flag[1]))) {
@ -496,7 +497,6 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
letter = parse[0]; letter = parse[0];
subletter = parse[1]; subletter = parse[1];
} }
*usedarg = FALSE; /* default is that we don't use the arg */
if(hit < 0) { if(hit < 0) {
for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) { for(j = 0; j < sizeof(aliases)/sizeof(aliases[0]); j++) {

View File

@ -49,7 +49,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
int res; int res;
FILE *file; FILE *file;
char filebuffer[512]; char filebuffer[512];
bool usedarg; bool usedarg = FALSE;
char *home; char *home;
int rc = 0; int rc = 0;
struct OperationConfig *operation = global->first; struct OperationConfig *operation = global->first;
@ -220,7 +220,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
#endif #endif
res = getparameter(option, param, &usedarg, global, operation); res = getparameter(option, param, &usedarg, global, operation);
if(param && *param && !usedarg) if(!res && param && *param && !usedarg)
/* we passed in a parameter that wasn't used! */ /* we passed in a parameter that wasn't used! */
res = PARAM_GOT_EXTRA_PARAMETER; res = PARAM_GOT_EXTRA_PARAMETER;