Skip to content

Commit a33af50

Browse files
committed
btrfs-progs: add constant for initial getopt values
Add constant for initial value to avoid unexpected clashes with user defined getopt values and shift the common size getopt values. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 92b57e4 commit a33af50

File tree

16 files changed

+32
-29
lines changed

16 files changed

+32
-29
lines changed

btrfs-corrupt-block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ int main(int argc, char **argv)
12361236

12371237
while(1) {
12381238
int c;
1239-
enum { GETOPT_VAL_BLOCK_GROUP = 256 };
1239+
enum { GETOPT_VAL_BLOCK_GROUP = GETOPT_VAL_FIRST };
12401240
static const struct option long_options[] = {
12411241
/* { "byte-count", 1, NULL, 'b' }, */
12421242
{ "logical", required_argument, NULL, 'l' },

btrfstune.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
818818
int fd = -1;
819819

820820
while(1) {
821-
enum { GETOPT_VAL_CSUM = 256 };
821+
enum { GETOPT_VAL_CSUM = GETOPT_VAL_FIRST };
822822
static const struct option long_options[] = {
823823
{ "help", no_argument, NULL, GETOPT_VAL_HELP},
824824
#if EXPERIMENTAL

check/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10412,7 +10412,7 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
1041210412

1041310413
while(1) {
1041410414
int c;
10415-
enum { GETOPT_VAL_REPAIR = 257, GETOPT_VAL_INIT_CSUM,
10415+
enum { GETOPT_VAL_REPAIR = GETOPT_VAL_FIRST, GETOPT_VAL_INIT_CSUM,
1041610416
GETOPT_VAL_INIT_EXTENT, GETOPT_VAL_CHECK_CSUM,
1041710417
GETOPT_VAL_READONLY, GETOPT_VAL_CHUNK_TREE,
1041810418
GETOPT_VAL_MODE, GETOPT_VAL_CLEAR_SPACE_CACHE,

cmds/balance.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,8 @@ static int cmd_balance_start(const struct cmd_struct *cmd,
407407

408408
optind = 0;
409409
while (1) {
410-
enum { GETOPT_VAL_FULL_BALANCE = 256,
411-
GETOPT_VAL_BACKGROUND = 257,
412-
GETOPT_VAL_ENQUEUE };
410+
enum { GETOPT_VAL_FULL_BALANCE = GETOPT_VAL_FIRST,
411+
GETOPT_VAL_BACKGROUND, GETOPT_VAL_ENQUEUE };
413412
static const struct option longopts[] = {
414413
{ "data", optional_argument, NULL, 'd'},
415414
{ "metadata", optional_argument, NULL, 'm' },

cmds/device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int cmd_device_add(const struct cmd_struct *cmd,
7474
optind = 0;
7575
while (1) {
7676
int c;
77-
enum { GETOPT_VAL_ENQUEUE = 256 };
77+
enum { GETOPT_VAL_ENQUEUE = GETOPT_VAL_FIRST };
7878
static const struct option long_options[] = {
7979
{ "nodiscard", optional_argument, NULL, 'K'},
8080
{ "force", no_argument, NULL, 'f'},
@@ -199,7 +199,7 @@ static int _cmd_device_remove(const struct cmd_struct *cmd,
199199
optind = 0;
200200
while (1) {
201201
int c;
202-
enum { GETOPT_VAL_ENQUEUE = 256 };
202+
enum { GETOPT_VAL_ENQUEUE = GETOPT_VAL_FIRST };
203203
static const struct option long_options[] = {
204204
{ "enqueue", no_argument, NULL, GETOPT_VAL_ENQUEUE},
205205
{ NULL, 0, NULL, 0}

cmds/inspect-dump-super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static int cmd_inspect_dump_super(const struct cmd_struct *cmd,
9292

9393
while (1) {
9494
int c;
95-
enum { GETOPT_VAL_BYTENR = 257 };
95+
enum { GETOPT_VAL_BYTENR = GETOPT_VAL_FIRST };
9696
static const struct option long_options[] = {
9797
{"all", no_argument, NULL, 'a'},
9898
{"bytenr", required_argument, NULL, GETOPT_VAL_BYTENR },

cmds/inspect-dump-tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
342342
optind = 0;
343343
while (1) {
344344
int c;
345-
enum { GETOPT_VAL_FOLLOW = 256, GETOPT_VAL_DFS, GETOPT_VAL_BFS,
345+
enum { GETOPT_VAL_FOLLOW = GETOPT_VAL_FIRST, GETOPT_VAL_DFS,
346+
GETOPT_VAL_BFS,
346347
GETOPT_VAL_NOSCAN, GETOPT_VAL_HIDE_NAMES,
347348
GETOPT_VAL_CSUM_HEADERS, GETOPT_VAL_CSUM_ITEMS,
348349
};

cmds/inspect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ static int cmd_inspect_min_dev_size(const struct cmd_struct *cmd,
648648
optind = 0;
649649
while (1) {
650650
int c;
651-
enum { GETOPT_VAL_DEVID = 256 };
651+
enum { GETOPT_VAL_DEVID = GETOPT_VAL_FIRST };
652652
static const struct option long_options[] = {
653653
{ "id", required_argument, NULL, GETOPT_VAL_DEVID },
654654
{NULL, 0, NULL, 0}

cmds/qgroup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ static int _cmd_qgroup_assign(const struct cmd_struct *cmd, int assign,
15351535

15361536
optind = 0;
15371537
while (1) {
1538-
enum { GETOPT_VAL_RESCAN = 256, GETOPT_VAL_NO_RESCAN };
1538+
enum { GETOPT_VAL_RESCAN = GETOPT_VAL_FIRST, GETOPT_VAL_NO_RESCAN };
15391539
static const struct option long_options[] = {
15401540
{ "rescan", no_argument, NULL, GETOPT_VAL_RESCAN },
15411541
{ "no-rescan", no_argument, NULL, GETOPT_VAL_NO_RESCAN },
@@ -1757,7 +1757,7 @@ static int cmd_qgroup_show(const struct cmd_struct *cmd, int argc, char **argv)
17571757
while (1) {
17581758
int c;
17591759
enum {
1760-
GETOPT_VAL_SORT = 256,
1760+
GETOPT_VAL_SORT = GETOPT_VAL_FIRST,
17611761
GETOPT_VAL_SYNC
17621762
};
17631763
static const struct option long_options[] = {

cmds/receive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv)
16021602
while (1) {
16031603
int c;
16041604
enum {
1605-
GETOPT_VAL_DUMP = 257,
1605+
GETOPT_VAL_DUMP = GETOPT_VAL_FIRST,
16061606
GETOPT_VAL_FORCE_DECOMPRESS,
16071607
};
16081608
static const struct option long_opts[] = {

0 commit comments

Comments
 (0)