btrfs-progs: cleanup: avoid to use literal for getopt val

Signed-off-by: David Sterba <dsterba@suse.cz>
master
Satoru Takeuchi 2014-12-19 14:31:54 +09:00 committed by David Sterba
parent ca8638eae3
commit 0e4e1b1ed9
3 changed files with 11 additions and 8 deletions

View File

@ -877,8 +877,8 @@ int cmd_filesystem_usage(int argc, char **argv)
{ "mbytes", no_argument, NULL, 'm'}, { "mbytes", no_argument, NULL, 'm'},
{ "gbytes", no_argument, NULL, 'g'}, { "gbytes", no_argument, NULL, 'g'},
{ "tbytes", no_argument, NULL, 't'}, { "tbytes", no_argument, NULL, 't'},
{ "si", no_argument, NULL, 256}, { "si", no_argument, NULL, GETOPT_VAL_SI},
{ "iec", no_argument, NULL, 257}, { "iec", no_argument, NULL, GETOPT_VAL_IEC},
}; };
int c = getopt_long(argc, argv, "bhHkmgtT", long_options, int c = getopt_long(argc, argv, "bhHkmgtT", long_options,
&long_index); &long_index);
@ -907,10 +907,10 @@ int cmd_filesystem_usage(int argc, char **argv)
case 'H': case 'H':
unit_mode = UNITS_HUMAN_DECIMAL; unit_mode = UNITS_HUMAN_DECIMAL;
break; break;
case 256: case GETOPT_VAL_SI:
units_set_mode(&unit_mode, UNITS_DECIMAL); units_set_mode(&unit_mode, UNITS_DECIMAL);
break; break;
case 257: case GETOPT_VAL_IEC:
units_set_mode(&unit_mode, UNITS_BINARY); units_set_mode(&unit_mode, UNITS_BINARY);
break; break;
case 'T': case 'T':

View File

@ -216,8 +216,8 @@ static int cmd_filesystem_df(int argc, char **argv)
{ "mbytes", no_argument, NULL, 'm'}, { "mbytes", no_argument, NULL, 'm'},
{ "gbytes", no_argument, NULL, 'g'}, { "gbytes", no_argument, NULL, 'g'},
{ "tbytes", no_argument, NULL, 't'}, { "tbytes", no_argument, NULL, 't'},
{ "si", no_argument, NULL, 256}, { "si", no_argument, NULL, GETOPT_VAL_SI},
{ "iec", no_argument, NULL, 257}, { "iec", no_argument, NULL, GETOPT_VAL_IEC},
}; };
int c = getopt_long(argc, argv, "bhHkmgt", long_options, int c = getopt_long(argc, argv, "bhHkmgt", long_options,
&long_index); &long_index);
@ -245,10 +245,10 @@ static int cmd_filesystem_df(int argc, char **argv)
case 'H': case 'H':
unit_mode = UNITS_HUMAN_DECIMAL; unit_mode = UNITS_HUMAN_DECIMAL;
break; break;
case 256: case GETOPT_VAL_SI:
units_set_mode(&unit_mode, UNITS_DECIMAL); units_set_mode(&unit_mode, UNITS_DECIMAL);
break; break;
case 257: case GETOPT_VAL_IEC:
units_set_mode(&unit_mode, UNITS_BINARY); units_set_mode(&unit_mode, UNITS_BINARY);
break; break;
default: default:

View File

@ -40,6 +40,9 @@
#define ARGV0_BUF_SIZE PATH_MAX #define ARGV0_BUF_SIZE PATH_MAX
#define GETOPT_VAL_SI 256
#define GETOPT_VAL_IEC 257
int check_argc_exact(int nargs, int expected); int check_argc_exact(int nargs, int expected);
int check_argc_min(int nargs, int expected); int check_argc_min(int nargs, int expected);
int check_argc_max(int nargs, int expected); int check_argc_max(int nargs, int expected);