[nss-drv] Use goto to reduce repeated code
Change-Id: Ia68d16df2c295023325d080bea6f818aae73ee6f
Signed-off-by: Stephen Wang <wstephen@codeaurora.org>
diff --git a/nss_ipv6.c b/nss_ipv6.c
index 2725c20..6256415 100644
--- a/nss_ipv6.c
+++ b/nss_ipv6.c
@@ -341,13 +341,7 @@
nss_ipv6_conn_cfg,
NSS_MIN_NUM_CONN,
NSS_MAX_TOTAL_NUM_CONN_IPV4_IPV6);
-
- /*
- * Restore the current_value to its previous state
- */
- nss_ipv6_conn_cfg = i6cfgp.current_value;
- up(&i6cfgp.sem);
- return NSS_FAILURE;
+ goto failure;
}
@@ -364,13 +358,7 @@
nss_warning("%p: nss_tx error setting IPv6 Connections: %d\n",
nss_ctx,
nss_ipv6_conn_cfg);
-
- /*
- * Restore the current_value to its previous state
- */
- nss_ipv6_conn_cfg = i6cfgp.current_value;
- up(&i6cfgp.sem);
- return NSS_FAILURE;
+ goto failure;
}
/*
@@ -379,13 +367,7 @@
ret = wait_for_completion_timeout(&i6cfgp.complete, msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
if (ret == 0) {
nss_warning("%p: Waiting for ack timed out\n", nss_ctx);
-
- /*
- * Restore the current_value to its previous state
- */
- nss_ipv6_conn_cfg = i6cfgp.current_value;
- up(&i6cfgp.sem);
- return NSS_FAILURE;
+ goto failure;
}
/*
@@ -394,16 +376,19 @@
* i6cfgp.num_conn_valid, which holds the user input
*/
if (NSS_FAILURE == i6cfgp.response) {
- /*
- * Restore the current_value to its previous state
- */
- nss_ipv6_conn_cfg = i6cfgp.current_value;
- up(&i6cfgp.sem);
- return NSS_FAILURE;
+ goto failure;
}
up(&i6cfgp.sem);
return NSS_SUCCESS;
+
+failure:
+ /*
+ * Restore the current_value to its previous state
+ */
+ nss_ipv6_conn_cfg = i6cfgp.current_value;
+ up(&i6cfgp.sem);
+ return NSS_FAILURE;
}
static ctl_table nss_ipv6_table[] = {