aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-11-08 19:54:16 +0100
committerStefan Sperling <ssperling@sysmocom.de>2018-11-09 10:05:09 +0000
commit01d4e035bf797fefc47b1a91014a0034fa70dd2a (patch)
tree7f134d60ed27889f6bf5a54423bf51c9e878fe83
parent6fb500f789425c3ca3c9f5d43e74f9bdf90ac2b2 (diff)
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
-rw-r--r--src/osmo-bsc/osmo_bsc_ctrl.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/osmo-bsc/osmo_bsc_ctrl.c b/src/osmo-bsc/osmo_bsc_ctrl.c
index a4a9a365f..80699f877 100644
--- a/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -512,8 +512,9 @@ static int get_net_timezone(struct ctrl_cmd *cmd, void *data)
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 @@ static int set_net_timezone(struct ctrl_cmd *cmd, void *data)
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;