Skip to content

Commit da1c7d2

Browse files
committed
More idiomatic way to define options
`opt` is an int, so we can use the range starting at CHAR_MAX+1. Signed-off-by: Nir Soffer <[email protected]>
1 parent 97d59a8 commit da1c7d2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

cli.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <limits.h>
12
#include <stdio.h>
23
#include <stdlib.h>
34
#include <string.h>
@@ -62,14 +63,17 @@ static void print_usage(const char *argv0) {
6263

6364
static void print_version() { puts(VERSION); }
6465

65-
#define CLI_OPTIONS_ID_SOCKET_GROUP -42
66-
#define CLI_OPTIONS_ID_VMNET_MODE -43
67-
#define CLI_OPTIONS_ID_VMNET_INTERFACE -44
68-
#define CLI_OPTIONS_ID_VMNET_GATEWAY -45
69-
#define CLI_OPTIONS_ID_VMNET_DHCP_END -46
70-
#define CLI_OPTIONS_ID_VMNET_MASK -47
71-
#define CLI_OPTIONS_ID_VMNET_INTERFACE_ID -48
72-
#define CLI_OPTIONS_ID_VMNET_NAT66_PREFIX -50
66+
enum {
67+
CLI_OPTIONS_ID_SOCKET_GROUP = CHAR_MAX + 1,
68+
CLI_OPTIONS_ID_VMNET_MODE,
69+
CLI_OPTIONS_ID_VMNET_INTERFACE,
70+
CLI_OPTIONS_ID_VMNET_GATEWAY,
71+
CLI_OPTIONS_ID_VMNET_DHCP_END,
72+
CLI_OPTIONS_ID_VMNET_MASK,
73+
CLI_OPTIONS_ID_VMNET_INTERFACE_ID,
74+
CLI_OPTIONS_ID_VMNET_NAT66_PREFIX,
75+
};
76+
7377
struct cli_options *cli_options_parse(int argc, char *argv[]) {
7478
struct cli_options *res = calloc(1, sizeof(*res));
7579
if (res == NULL) {

0 commit comments

Comments
 (0)