openvpn: Remove useless conditional block in parse_state

tok != NULL is already checked in the for loop conditions.

Change-Id: I86e42e4537060b2ed8c860c0b71a225c5fe026c7
This commit is contained in:
Pau Espin 2019-03-15 20:56:42 +01:00
parent 3d13718ce7
commit 778ac848d3
1 changed files with 18 additions and 19 deletions

View File

@ -98,25 +98,24 @@ static char *parse_state(struct msgb *msg, struct openvpn_client *vpn)
}
for (tok = strtok(tmp, ","), i = 0; tok && i < MAX_RESP_COMPONENTS; tok = strtok(NULL, ",")) {
if (tok) { /* Parse csv string and pick interesting tokens while ignoring the rest. */
switch (i++) {
/* case 0: unix/date time, not needed */
case 1:
update_name(vpn->rem_cfg, tok);
break;
case 2:
snprintf(buf, sizeof(buf), "%s (%s)", vpn->rem_cfg->name, tok);
update_name(vpn->rem_cfg, buf);
case 3:
osmo_talloc_replace_string(vpn->rem_cfg, &vpn->tun_ip, tok);
break;
case 4:
update_host(vpn->rem_cfg, tok);
break;
case 5:
vpn->rem_cfg->remote_port = atoi(tok);
break;
}
/* Parse csv string and pick interesting tokens while ignoring the rest. */
switch (i++) {
/* case 0: unix/date time, not needed */
case 1:
update_name(vpn->rem_cfg, tok);
break;
case 2:
snprintf(buf, sizeof(buf), "%s (%s)", vpn->rem_cfg->name, tok);
update_name(vpn->rem_cfg, buf);
case 3:
osmo_talloc_replace_string(vpn->rem_cfg, &vpn->tun_ip, tok);
break;
case 4:
update_host(vpn->rem_cfg, tok);
break;
case 5:
vpn->rem_cfg->remote_port = atoi(tok);
break;
}
}
return NULL;