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>
This commit is contained in:
David Sterba 2022-06-21 02:20:21 +02:00
parent 92b57e4fd8
commit a33af50c52
16 changed files with 31 additions and 28 deletions

View file

@ -1236,7 +1236,7 @@ int main(int argc, char **argv)
while(1) {
int c;
enum { GETOPT_VAL_BLOCK_GROUP = 256 };
enum { GETOPT_VAL_BLOCK_GROUP = GETOPT_VAL_FIRST };
static const struct option long_options[] = {
/* { "byte-count", 1, NULL, 'b' }, */
{ "logical", required_argument, NULL, 'l' },

View file

@ -818,7 +818,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
int fd = -1;
while(1) {
enum { GETOPT_VAL_CSUM = 256 };
enum { GETOPT_VAL_CSUM = GETOPT_VAL_FIRST };
static const struct option long_options[] = {
{ "help", no_argument, NULL, GETOPT_VAL_HELP},
#if EXPERIMENTAL

View file

@ -10412,7 +10412,7 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
while(1) {
int c;
enum { GETOPT_VAL_REPAIR = 257, GETOPT_VAL_INIT_CSUM,
enum { GETOPT_VAL_REPAIR = GETOPT_VAL_FIRST, GETOPT_VAL_INIT_CSUM,
GETOPT_VAL_INIT_EXTENT, GETOPT_VAL_CHECK_CSUM,
GETOPT_VAL_READONLY, GETOPT_VAL_CHUNK_TREE,
GETOPT_VAL_MODE, GETOPT_VAL_CLEAR_SPACE_CACHE,

View file

@ -407,9 +407,8 @@ static int cmd_balance_start(const struct cmd_struct *cmd,
optind = 0;
while (1) {
enum { GETOPT_VAL_FULL_BALANCE = 256,
GETOPT_VAL_BACKGROUND = 257,
GETOPT_VAL_ENQUEUE };
enum { GETOPT_VAL_FULL_BALANCE = GETOPT_VAL_FIRST,
GETOPT_VAL_BACKGROUND, GETOPT_VAL_ENQUEUE };
static const struct option longopts[] = {
{ "data", optional_argument, NULL, 'd'},
{ "metadata", optional_argument, NULL, 'm' },

View file

@ -74,7 +74,7 @@ static int cmd_device_add(const struct cmd_struct *cmd,
optind = 0;
while (1) {
int c;
enum { GETOPT_VAL_ENQUEUE = 256 };
enum { GETOPT_VAL_ENQUEUE = GETOPT_VAL_FIRST };
static const struct option long_options[] = {
{ "nodiscard", optional_argument, NULL, 'K'},
{ "force", no_argument, NULL, 'f'},
@ -199,7 +199,7 @@ static int _cmd_device_remove(const struct cmd_struct *cmd,
optind = 0;
while (1) {
int c;
enum { GETOPT_VAL_ENQUEUE = 256 };
enum { GETOPT_VAL_ENQUEUE = GETOPT_VAL_FIRST };
static const struct option long_options[] = {
{ "enqueue", no_argument, NULL, GETOPT_VAL_ENQUEUE},
{ NULL, 0, NULL, 0}

View file

@ -92,7 +92,7 @@ static int cmd_inspect_dump_super(const struct cmd_struct *cmd,
while (1) {
int c;
enum { GETOPT_VAL_BYTENR = 257 };
enum { GETOPT_VAL_BYTENR = GETOPT_VAL_FIRST };
static const struct option long_options[] = {
{"all", no_argument, NULL, 'a'},
{"bytenr", required_argument, NULL, GETOPT_VAL_BYTENR },

View file

@ -342,7 +342,8 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
optind = 0;
while (1) {
int c;
enum { GETOPT_VAL_FOLLOW = 256, GETOPT_VAL_DFS, GETOPT_VAL_BFS,
enum { GETOPT_VAL_FOLLOW = GETOPT_VAL_FIRST, GETOPT_VAL_DFS,
GETOPT_VAL_BFS,
GETOPT_VAL_NOSCAN, GETOPT_VAL_HIDE_NAMES,
GETOPT_VAL_CSUM_HEADERS, GETOPT_VAL_CSUM_ITEMS,
};

View file

@ -648,7 +648,7 @@ static int cmd_inspect_min_dev_size(const struct cmd_struct *cmd,
optind = 0;
while (1) {
int c;
enum { GETOPT_VAL_DEVID = 256 };
enum { GETOPT_VAL_DEVID = GETOPT_VAL_FIRST };
static const struct option long_options[] = {
{ "id", required_argument, NULL, GETOPT_VAL_DEVID },
{NULL, 0, NULL, 0}

View file

@ -1535,7 +1535,7 @@ static int _cmd_qgroup_assign(const struct cmd_struct *cmd, int assign,
optind = 0;
while (1) {
enum { GETOPT_VAL_RESCAN = 256, GETOPT_VAL_NO_RESCAN };
enum { GETOPT_VAL_RESCAN = GETOPT_VAL_FIRST, GETOPT_VAL_NO_RESCAN };
static const struct option long_options[] = {
{ "rescan", no_argument, NULL, GETOPT_VAL_RESCAN },
{ "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)
while (1) {
int c;
enum {
GETOPT_VAL_SORT = 256,
GETOPT_VAL_SORT = GETOPT_VAL_FIRST,
GETOPT_VAL_SYNC
};
static const struct option long_options[] = {

View file

@ -1602,7 +1602,7 @@ static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv)
while (1) {
int c;
enum {
GETOPT_VAL_DUMP = 257,
GETOPT_VAL_DUMP = GETOPT_VAL_FIRST,
GETOPT_VAL_FORCE_DECOMPRESS,
};
static const struct option long_opts[] = {

View file

@ -147,7 +147,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
optind = 0;
while (1) {
int c;
enum { GETOPT_VAL_ENQUEUE = 256 };
enum { GETOPT_VAL_ENQUEUE = GETOPT_VAL_FIRST };
static const struct option long_options[] = {
{ "enqueue", no_argument, NULL, GETOPT_VAL_ENQUEUE},
{ "nodiscard", no_argument, NULL, 'K' },

View file

@ -1391,7 +1391,7 @@ static int cmd_restore(const struct cmd_struct *cmd, int argc, char **argv)
optind = 0;
while (1) {
int opt;
enum { GETOPT_VAL_PATH_REGEX = 256 };
enum { GETOPT_VAL_PATH_REGEX = GETOPT_VAL_FIRST };
static const struct option long_options[] = {
{ "path-regex", required_argument, NULL,
GETOPT_VAL_PATH_REGEX },

View file

@ -538,7 +538,7 @@ static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
optind = 0;
while (1) {
enum {
GETOPT_VAL_SEND_NO_DATA = 256,
GETOPT_VAL_SEND_NO_DATA = GETOPT_VAL_FIRST,
GETOPT_VAL_PROTO,
GETOPT_VAL_COMPRESSED_DATA,
};

View file

@ -17,16 +17,19 @@
#ifndef __BTRFS_HELP_H__
#define __BTRFS_HELP_H__
#define GETOPT_VAL_SI 256
#define GETOPT_VAL_IEC 257
#define GETOPT_VAL_RAW 258
#define GETOPT_VAL_HUMAN_READABLE 259
#define GETOPT_VAL_KBYTES 260
#define GETOPT_VAL_MBYTES 261
#define GETOPT_VAL_GBYTES 262
#define GETOPT_VAL_TBYTES 263
/* User defined long options first option */
#define GETOPT_VAL_FIRST 256
#define GETOPT_VAL_HELP 270
#define GETOPT_VAL_SI 512
#define GETOPT_VAL_IEC 513
#define GETOPT_VAL_RAW 514
#define GETOPT_VAL_HUMAN_READABLE 515
#define GETOPT_VAL_KBYTES 516
#define GETOPT_VAL_MBYTES 517
#define GETOPT_VAL_GBYTES 518
#define GETOPT_VAL_TBYTES 519
#define GETOPT_VAL_HELP 520
#define ARGV0_BUF_SIZE PATH_MAX

View file

@ -1832,7 +1832,7 @@ int BOX_MAIN(convert)(int argc, char *argv[])
printf("btrfs-convert from %s\n\n", PACKAGE_STRING);
while(1) {
enum { GETOPT_VAL_NO_PROGRESS = 256, GETOPT_VAL_CHECKSUM,
enum { GETOPT_VAL_NO_PROGRESS = GETOPT_VAL_FIRST, GETOPT_VAL_CHECKSUM,
GETOPT_VAL_UUID };
static const struct option long_options[] = {
{ "no-progress", no_argument, NULL,

View file

@ -1021,7 +1021,7 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
while(1) {
int c;
enum {
GETOPT_VAL_SHRINK = 257,
GETOPT_VAL_SHRINK = GETOPT_VAL_FIRST,
GETOPT_VAL_CHECKSUM,
GETOPT_VAL_GLOBAL_ROOTS,
};