Laszlo Ersek
2023-Apr-14 07:59 UTC
[Libguestfs] [libnbd PATCH 1/4] copy: rename (LONG|SHORT)_OPTIONS to (LONG|SHORT)_OPTIONS_OPTION
Two of the enum constants that denote command line options are inconsistently named with the rest: all identifiers should be <purpose>_OPTION, but LONG_OPTIONS and SHORT_OPTIONS (which are supposed to list the long and short options) don't conform. Rename them. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516 Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- copy/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/copy/main.c b/copy/main.c index f9a714c4f677..bb67e97ff97a 100644 --- a/copy/main.c +++ b/copy/main.c @@ -107,8 +107,8 @@ main (int argc, char *argv[]) { enum { HELP_OPTION = CHAR_MAX + 1, - LONG_OPTIONS, - SHORT_OPTIONS, + LONG_OPTIONS_OPTION, + SHORT_OPTIONS_OPTION, ALLOCATED_OPTION, DESTINATION_IS_ZERO_OPTION, FLUSH_OPTION, @@ -120,7 +120,7 @@ main (int argc, char *argv[]) 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 }, + { "long-options", no_argument, NULL, LONG_OPTIONS_OPTION }, { "allocated", no_argument, NULL, ALLOCATED_OPTION }, { "connections", required_argument, NULL, 'C' }, { "destination-is-zero",no_argument, NULL, DESTINATION_IS_ZERO_OPTION }, @@ -130,7 +130,7 @@ main (int argc, char *argv[]) { "queue-size", required_argument, NULL, QUEUE_SIZE_OPTION }, { "request-size", required_argument, NULL, REQUEST_SIZE_OPTION }, { "requests", required_argument, NULL, 'R' }, - { "short-options", no_argument, NULL, SHORT_OPTIONS }, + { "short-options", no_argument, NULL, SHORT_OPTIONS_OPTION }, { "sparse", required_argument, NULL, 'S' }, { "synchronous", no_argument, NULL, SYNCHRONOUS_OPTION }, { "target-is-zero", no_argument, NULL, DESTINATION_IS_ZERO_OPTION }, @@ -155,7 +155,7 @@ main (int argc, char *argv[]) case HELP_OPTION: usage (stdout, EXIT_SUCCESS); - case LONG_OPTIONS: + case LONG_OPTIONS_OPTION: 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,7 +163,7 @@ main (int argc, char *argv[]) } exit (EXIT_SUCCESS); - case SHORT_OPTIONS: + case SHORT_OPTIONS_OPTION: for (i = 0; short_options[i]; ++i) { if (short_options[i] != ':' && short_options[i] != '+') printf ("-%c\n", short_options[i]);
Richard W.M. Jones
2023-Apr-14 08:11 UTC
[Libguestfs] [libnbd PATCH 1/4] copy: rename (LONG|SHORT)_OPTIONS to (LONG|SHORT)_OPTIONS_OPTION
On Fri, Apr 14, 2023 at 09:59:53AM +0200, Laszlo Ersek wrote:> Two of the enum constants that denote command line options are > inconsistently named with the rest: all identifiers should be > <purpose>_OPTION, but LONG_OPTIONS and SHORT_OPTIONS (which are supposed > to list the long and short options) don't conform. Rename them. > > Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172516 > Signed-off-by: Laszlo Ersek <lersek at redhat.com> > --- > copy/main.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/copy/main.c b/copy/main.c > index f9a714c4f677..bb67e97ff97a 100644 > --- a/copy/main.c > +++ b/copy/main.c > @@ -107,8 +107,8 @@ main (int argc, char *argv[]) > { > enum { > HELP_OPTION = CHAR_MAX + 1, > - LONG_OPTIONS, > - SHORT_OPTIONS, > + LONG_OPTIONS_OPTION, > + SHORT_OPTIONS_OPTION, > ALLOCATED_OPTION, > DESTINATION_IS_ZERO_OPTION, > FLUSH_OPTION, > @@ -120,7 +120,7 @@ main (int argc, char *argv[]) > 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 }, > + { "long-options", no_argument, NULL, LONG_OPTIONS_OPTION }, > { "allocated", no_argument, NULL, ALLOCATED_OPTION }, > { "connections", required_argument, NULL, 'C' }, > { "destination-is-zero",no_argument, NULL, DESTINATION_IS_ZERO_OPTION }, > @@ -130,7 +130,7 @@ main (int argc, char *argv[]) > { "queue-size", required_argument, NULL, QUEUE_SIZE_OPTION }, > { "request-size", required_argument, NULL, REQUEST_SIZE_OPTION }, > { "requests", required_argument, NULL, 'R' }, > - { "short-options", no_argument, NULL, SHORT_OPTIONS }, > + { "short-options", no_argument, NULL, SHORT_OPTIONS_OPTION }, > { "sparse", required_argument, NULL, 'S' }, > { "synchronous", no_argument, NULL, SYNCHRONOUS_OPTION }, > { "target-is-zero", no_argument, NULL, DESTINATION_IS_ZERO_OPTION }, > @@ -155,7 +155,7 @@ main (int argc, char *argv[]) > case HELP_OPTION: > usage (stdout, EXIT_SUCCESS); > > - case LONG_OPTIONS: > + case LONG_OPTIONS_OPTION: > 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,7 +163,7 @@ main (int argc, char *argv[]) > } > exit (EXIT_SUCCESS); > > - case SHORT_OPTIONS: > + case SHORT_OPTIONS_OPTION: > for (i = 0; short_options[i]; ++i) { > if (short_options[i] != ':' && short_options[i] != '+') > printf ("-%c\n", short_options[i]);Assuming (from the cover message) that the same will be done later for nbdinfo, fuse etc then ACK. I was going to say that we use LONG_OPTIONS & SHORT_OPTIONS elsewhere, but actually we don't. We use --long-options and --short-options extensively (eg. in guestfs-tools) but those are implemented differently. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Possibly Parallel Threads
- [libnbd PATCH 1/4] copy: rename (LONG|SHORT)_OPTIONS to (LONG|SHORT)_OPTIONS_OPTION
- [libnbd PATCH 2/4] copy: rename <purpose>_OPTION to OPT_<purpose>
- [libnbd PATCH 1/4] copy: rename (LONG|SHORT)_OPTIONS to (LONG|SHORT)_OPTIONS_OPTION
- [libnbd PATCH 0/4] copy: wrap source code at 80 characters
- [libnbd PATCH v2 0/3] copy: wrap source code at 80 characters