Rename <purpose>_OPTION to OPT_<purpose> for two reasons: - it is more idiomatic for enum constants to have the same prefix than for them to have the same suffix,
- we hew away three characters (length-wise) from each option name, which happens to reduce the max width of "copy/main.c" to 79 characters. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516 Signed-off-by: Laszlo Ersek <ler...@redhat.com> --- copy/main.c | 62 ++++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/copy/main.c b/copy/main.c index bb67e97ff97a..8055b3a656ba 100644 --- a/copy/main.c +++ b/copy/main.c @@ -106,34 +106,34 @@ int main (int argc, char *argv[]) { enum { - HELP_OPTION = CHAR_MAX + 1, - LONG_OPTIONS_OPTION, - SHORT_OPTIONS_OPTION, - ALLOCATED_OPTION, - DESTINATION_IS_ZERO_OPTION, - FLUSH_OPTION, - NO_EXTENTS_OPTION, - QUEUE_SIZE_OPTION, - REQUEST_SIZE_OPTION, - SYNCHRONOUS_OPTION, + OPT_HELP = CHAR_MAX + 1, + OPT_LONG_OPTIONS, + OPT_SHORT_OPTIONS, + OPT_ALLOCATED, + OPT_DESTINATION_IS_ZERO, + OPT_FLUSH, + OPT_NO_EXTENTS, + OPT_QUEUE_SIZE, + OPT_REQUEST_SIZE, + OPT_SYNCHRONOUS, }; const char *short_options = "C:pR:S:T:vV"; const struct option long_options[] = { - { "help", no_argument, NULL, HELP_OPTION }, - { "long-options", no_argument, NULL, LONG_OPTIONS_OPTION }, - { "allocated", no_argument, NULL, ALLOCATED_OPTION }, + { "help", no_argument, NULL, OPT_HELP }, + { "long-options", no_argument, NULL, OPT_LONG_OPTIONS }, + { "allocated", no_argument, NULL, OPT_ALLOCATED }, { "connections", required_argument, NULL, 'C' }, - { "destination-is-zero",no_argument, NULL, DESTINATION_IS_ZERO_OPTION }, - { "flush", no_argument, NULL, FLUSH_OPTION }, - { "no-extents", no_argument, NULL, NO_EXTENTS_OPTION }, + { "destination-is-zero",no_argument, NULL, OPT_DESTINATION_IS_ZERO }, + { "flush", no_argument, NULL, OPT_FLUSH }, + { "no-extents", no_argument, NULL, OPT_NO_EXTENTS }, { "progress", optional_argument, NULL, 'p' }, - { "queue-size", required_argument, NULL, QUEUE_SIZE_OPTION }, - { "request-size", required_argument, NULL, REQUEST_SIZE_OPTION }, + { "queue-size", required_argument, NULL, OPT_QUEUE_SIZE }, + { "request-size", required_argument, NULL, OPT_REQUEST_SIZE }, { "requests", required_argument, NULL, 'R' }, - { "short-options", no_argument, NULL, SHORT_OPTIONS_OPTION }, + { "short-options", no_argument, NULL, OPT_SHORT_OPTIONS }, { "sparse", required_argument, NULL, 'S' }, - { "synchronous", no_argument, NULL, SYNCHRONOUS_OPTION }, - { "target-is-zero", no_argument, NULL, DESTINATION_IS_ZERO_OPTION }, + { "synchronous", no_argument, NULL, OPT_SYNCHRONOUS }, + { "target-is-zero", no_argument, NULL, OPT_DESTINATION_IS_ZERO }, { "threads", required_argument, NULL, 'T' }, { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, @@ -152,10 +152,10 @@ main (int argc, char *argv[]) break; switch (c) { - case HELP_OPTION: + case OPT_HELP: usage (stdout, EXIT_SUCCESS); - case LONG_OPTIONS_OPTION: + case OPT_LONG_OPTIONS: for (i = 0; long_options[i].name != NULL; ++i) { if (strcmp (long_options[i].name, "long-options") != 0 && strcmp (long_options[i].name, "short-options") != 0) @@ -163,30 +163,30 @@ main (int argc, char *argv[]) } exit (EXIT_SUCCESS); - case SHORT_OPTIONS_OPTION: + case OPT_SHORT_OPTIONS: for (i = 0; short_options[i]; ++i) { if (short_options[i] != ':' && short_options[i] != '+') printf ("-%c\n", short_options[i]); } exit (EXIT_SUCCESS); - case ALLOCATED_OPTION: + case OPT_ALLOCATED: allocated = true; break; - case DESTINATION_IS_ZERO_OPTION: + case OPT_DESTINATION_IS_ZERO: destination_is_zero = true; break; - case FLUSH_OPTION: + case OPT_FLUSH: flush = true; break; - case NO_EXTENTS_OPTION: + case OPT_NO_EXTENTS: extents = false; break; - case SYNCHRONOUS_OPTION: + case OPT_SYNCHRONOUS: synchronous = true; break; @@ -209,7 +209,7 @@ main (int argc, char *argv[]) } break; - case QUEUE_SIZE_OPTION: + case OPT_QUEUE_SIZE: if (sscanf (optarg, "%u", &queue_size) != 1) { fprintf (stderr, "%s: --queue-size: could not parse: %s\n", prog, optarg); @@ -217,7 +217,7 @@ main (int argc, char *argv[]) } break; - case REQUEST_SIZE_OPTION: + case OPT_REQUEST_SIZE: if (sscanf (optarg, "%u", &request_size) != 1) { fprintf (stderr, "%s: --request-size: could not parse: %s\n", prog, optarg); _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs