[Openvpn-devel,v2] options: make the options mode an enum
Commit Message
From: Razvan Cojocaru <razvanc@mailbox.org>
Turn the MODE_* defines into enum options_mode and use it for the mode
fields and parameters. With both modes being distinct enum types,
-Wenum-compare catches comparing a context mode against an options
mode.
Change-Id: Ie902dbc45e4aca0c72bc4b4e8cc1e17d29b47aa1
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2334
---
This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2334
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Lev Stipakov <lstipakov@gmail.com>
@@ -255,7 +255,7 @@
}
static bool
-dco_check_option_ce(const struct connection_entry *ce, msglvl_t msglevel, int mode)
+dco_check_option_ce(const struct connection_entry *ce, msglvl_t msglevel, enum options_mode mode)
{
if (ce->fragment)
{
@@ -2309,7 +2309,7 @@
}
static void
-options_postprocess_mutate_le(const struct connection_entry *ce, struct local_entry *le, int mode)
+options_postprocess_mutate_le(const struct connection_entry *ce, struct local_entry *le, enum options_mode mode)
{
/* use the global port if none is specified */
if (!le->port)
@@ -252,6 +252,13 @@
struct verify_hash_list *next;
};
+/** Major mode */
+enum options_mode
+{
+ MODE_POINT_TO_POINT,
+ MODE_SERVER,
+};
+
/* Command line options */
struct options
{
@@ -260,10 +267,7 @@
/* first config file */
const char *config;
- /* major mode */
-#define MODE_POINT_TO_POINT 0
-#define MODE_SERVER 1
- int mode;
+ enum options_mode mode;
/* enable forward compatibility for post-2.1 features */
bool forward_compatible;
@@ -324,7 +324,7 @@
/* from command line */
bool single_session;
- int mode;
+ enum options_mode mode;
bool pull;
/**
* The detail of info we push in peer info