pacman.c: remove unnecessary optarg checks

getopt takes care of making sure that options that require a value have
one.  These checks were only added to silence clang, which no longer
complains about optarg being unchecked, and newer options already use
optarg unchecked.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2014-01-13 23:01:41 -05:00 committed by Allan McRae
parent 8a434aeb46
commit ffe7f6d161
1 changed files with 0 additions and 11 deletions

View File

@ -321,8 +321,6 @@ static void handler(int signum)
cleanup(128 + signum); cleanup(128 + signum);
} }
#define check_optarg() if(!optarg) { return 1; }
static void invalid_opt(int used, const char *opt1, const char *opt2) static void invalid_opt(int used, const char *opt1, const char *opt2)
{ {
if(used) { if(used) {
@ -337,7 +335,6 @@ static int parsearg_util_addlist(alpm_list_t **list)
{ {
char *i, *save; char *i, *save;
check_optarg();
for(i = strtok_r(optarg, ",", &save); i; i = strtok_r(NULL, ",", &save)) { for(i = strtok_r(optarg, ",", &save); i; i = strtok_r(NULL, ",", &save)) {
*list = alpm_list_add(*list, strdup(i)); *list = alpm_list_add(*list, strdup(i));
@ -393,16 +390,13 @@ static int parsearg_global(int opt)
{ {
switch(opt) { switch(opt) {
case OP_ARCH: case OP_ARCH:
check_optarg();
config_set_arch(optarg); config_set_arch(optarg);
break; break;
case OP_ASK: case OP_ASK:
check_optarg();
config->noask = 1; config->noask = 1;
config->ask = (unsigned int)atoi(optarg); config->ask = (unsigned int)atoi(optarg);
break; break;
case OP_CACHEDIR: case OP_CACHEDIR:
check_optarg();
config->cachedirs = alpm_list_add(config->cachedirs, strdup(optarg)); config->cachedirs = alpm_list_add(config->cachedirs, strdup(optarg));
break; break;
case OP_COLOR: case OP_COLOR:
@ -420,7 +414,6 @@ static int parsearg_global(int opt)
enable_colors(config->color); enable_colors(config->color);
break; break;
case OP_CONFIG: case OP_CONFIG:
check_optarg();
if(config->configfile) { if(config->configfile) {
free(config->configfile); free(config->configfile);
} }
@ -453,7 +446,6 @@ static int parsearg_global(int opt)
config->gpgdir = strdup(optarg); config->gpgdir = strdup(optarg);
break; break;
case OP_LOGFILE: case OP_LOGFILE:
check_optarg();
config->logfile = strndup(optarg, PATH_MAX); config->logfile = strndup(optarg, PATH_MAX);
break; break;
case OP_NOCONFIRM: case OP_NOCONFIRM:
@ -461,12 +453,10 @@ static int parsearg_global(int opt)
break; break;
case OP_DBPATH: case OP_DBPATH:
case 'b': case 'b':
check_optarg();
config->dbpath = strdup(optarg); config->dbpath = strdup(optarg);
break; break;
case OP_ROOT: case OP_ROOT:
case 'r': case 'r':
check_optarg();
config->rootdir = strdup(optarg); config->rootdir = strdup(optarg);
break; break;
case OP_VERBOSE: case OP_VERBOSE:
@ -632,7 +622,6 @@ static int parsearg_trans(int opt)
config->print = 1; config->print = 1;
break; break;
case OP_PRINTFORMAT: case OP_PRINTFORMAT:
check_optarg();
config->print = 1; config->print = 1;
config->print_format = strdup(optarg); config->print_format = strdup(optarg);
break; break;