]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
do_persist_tuntap: remove indentation level
authorLev Stipakov <lev@openvpn.net>
Fri, 9 Sep 2022 06:41:26 +0000 (09:41 +0300)
committerGert Doering <gert@greenie.muc.de>
Fri, 9 Sep 2022 08:10:05 +0000 (10:10 +0200)
Reverse if condition - this allows us to get rid of
indentation level, which makes code easier to read.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20220909064126.482-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25153.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/init.c

index 9917cefec2ab4ffa359d7bb376129a1b6e0b7e20..f846cefd37154592e19c09510b52d2ff04a6bf83 100644 (file)
@@ -1057,57 +1057,59 @@ do_genkey(const struct options *options)
 bool
 do_persist_tuntap(struct options *options, openvpn_net_ctx_t *ctx)
 {
-    if (options->persist_config)
-    {
-        /* sanity check on options for --mktun or --rmtun */
-        notnull(options->dev, "TUN/TAP device (--dev)");
-        if (options->ce.remote || options->ifconfig_local
-            || options->ifconfig_remote_netmask
-            || options->shared_secret_file
-            || options->tls_server || options->tls_client
-            )
-        {
-            msg(M_FATAL|M_OPTERR,
-                "options --mktun or --rmtun should only be used together with --dev");
-        }
+    if (!options->persist_config)
+    {
+        return false;
+    }
 
-#if defined(ENABLE_DCO)
-        if (dco_enabled(options))
-        {
-            /* creating a DCO interface via --mktun is not supported as it does not
-             * make much sense. Since DCO is enabled by default, people may run into
-             * this without knowing, therefore this case should be properly handled.
-             *
-             * Disable DCO if --mktun was provided and print a message to let
-             * user know.
-             */
-            if (dev_type_enum(options->dev, options->dev_type) == DEV_TYPE_TUN)
-            {
-                msg(M_WARN, "Note: --mktun does not support DCO. Creating TUN interface.");
-            }
+    /* sanity check on options for --mktun or --rmtun */
+    notnull(options->dev, "TUN/TAP device (--dev)");
+    if (options->ce.remote || options->ifconfig_local
+        || options->ifconfig_remote_netmask
+        || options->shared_secret_file
+        || options->tls_server || options->tls_client
+        )
+    {
+        msg(M_FATAL|M_OPTERR,
+            "options --mktun or --rmtun should only be used together with --dev");
+    }
 
-            options->tuntap_options.disable_dco = true;
+#if defined(ENABLE_DCO)
+    if (dco_enabled(options))
+    {
+        /* creating a DCO interface via --mktun is not supported as it does not
+         * make much sense. Since DCO is enabled by default, people may run into
+         * this without knowing, therefore this case should be properly handled.
+         *
+         * Disable DCO if --mktun was provided and print a message to let
+         * user know.
+         */
+        if (dev_type_enum(options->dev, options->dev_type) == DEV_TYPE_TUN)
+        {
+            msg(M_WARN, "Note: --mktun does not support DCO. Creating TUN interface.");
         }
+
+        options->tuntap_options.disable_dco = true;
+    }
 #endif
 
 #ifdef ENABLE_FEATURE_TUN_PERSIST
-        tuncfg(options->dev, options->dev_type, options->dev_node,
-               options->persist_mode,
-               options->username, options->groupname, &options->tuntap_options,
-               ctx);
-        if (options->persist_mode && options->lladdr)
-        {
-            set_lladdr(ctx, options->dev, options->lladdr, NULL);
-        }
-        return true;
+    tuncfg(options->dev, options->dev_type, options->dev_node,
+           options->persist_mode,
+           options->username, options->groupname, &options->tuntap_options,
+           ctx);
+    if (options->persist_mode && options->lladdr)
+    {
+        set_lladdr(ctx, options->dev, options->lladdr, NULL);
+    }
+    return true;
 #else  /* ifdef ENABLE_FEATURE_TUN_PERSIST */
-        msg( M_FATAL|M_OPTERR,
-             "options --mktun and --rmtun are not available on your operating "
-             "system.  Please check 'man tun' (or 'tap'), whether your system "
-             "supports using 'ifconfig %s create' / 'destroy' to create/remove "
-             "persistent tunnel interfaces.", options->dev );
+    msg(M_FATAL|M_OPTERR,
+        "options --mktun and --rmtun are not available on your operating "
+        "system.  Please check 'man tun' (or 'tap'), whether your system "
+        "supports using 'ifconfig %s create' / 'destroy' to create/remove "
+        "persistent tunnel interfaces.", options->dev );
 #endif
-    }
     return false;
 }