Change in osmo-bsc[master]: re-order condition checks for clarity

Stefan Sperling gerrit-no-reply at lists.osmocom.org
Fri Nov 9 10:05:09 UTC 2018


Stefan Sperling has submitted this change and it was merged. ( https://gerrit.osmocom.org/11698 )

Change subject: re-order condition checks for clarity
......................................................................

re-order condition checks for clarity

Coverity points out that conditional checks in set_net_timezone()
depend on each other: The value of 'override' depends on 'hourstr'
being non-NULL. Nest these conditional checks such that this
dependency becomes obvious.

No functional change.

Change-Id: I10dece1e1d9e039fb9f03be89b3a202cb077b026
Related: CID#148208
---
M src/osmo-bsc/osmo_bsc_ctrl.c
1 file changed, 9 insertions(+), 10 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bsc/osmo_bsc_ctrl.c b/src/osmo-bsc/osmo_bsc_ctrl.c
index a4a9a36..80699f8 100644
--- a/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -512,8 +512,9 @@
 static int set_net_timezone(struct ctrl_cmd *cmd, void *data)
 {
 	char *saveptr, *hourstr, *minstr, *dststr, *tmp = 0;
-	int override;
+	int override = 0;
 	struct gsm_network *net = (struct gsm_network*)cmd->node;
+	struct gsm_tz *tz = &net->tz;
 
 	tmp = talloc_strdup(cmd, cmd->value);
 	if (!tmp)
@@ -523,19 +524,17 @@
 	minstr = strtok_r(NULL, ",", &saveptr);
 	dststr = strtok_r(NULL, ",", &saveptr);
 
-	override = 0;
-
-	if (hourstr != NULL)
+	if (hourstr != NULL) {
 		override = strcasecmp(hourstr, "off") != 0;
+		if (override) {
+			tz->hr  = atol(hourstr);
+			tz->mn  = minstr ? atol(minstr) : 0;
+			tz->dst = dststr ? atol(dststr) : 0;
+		}
+	}
 
-	struct gsm_tz *tz = &net->tz;
 	tz->override = override;
 
-	if (override) {
-		tz->hr  = hourstr ? atol(hourstr) : 0;
-		tz->mn  = minstr ? atol(minstr) : 0;
-		tz->dst = dststr ? atol(dststr) : 0;
-	}
 
 	talloc_free(tmp);
 	tmp = NULL;

-- 
To view, visit https://gerrit.osmocom.org/11698
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I10dece1e1d9e039fb9f03be89b3a202cb077b026
Gerrit-Change-Number: 11698
Gerrit-PatchSet: 2
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <ssperling at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181109/bc3e407f/attachment.html>


More information about the gerrit-log mailing list