Skip to content

Commit 0b8f7d8

Browse files
jerome-pouillerdanieldegrasse
authored andcommitted
drivers: wifi: siwx91x: Uniformize error management
Usually, the exception are treated in a condition before the nominal case: ret = f(); if (ret) { return -EXXX; } ... nominal case ... siwx91x_on_join_ipv4() and siwx91x_on_join_ipv6() didn't follow this pattern. Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
1 parent a89dc21 commit 0b8f7d8

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

drivers/wifi/siwx91x/siwx91x_wifi_socket.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ void siwx91x_on_join_ipv4(struct siwx91x_dev *sidev)
7070
}
7171
/* FIXME: support for static IP configuration */
7272
ret = sl_si91x_configure_ip_address(&ip_config4, SL_SI91X_WIFI_CLIENT_VAP_ID);
73-
if (!ret) {
74-
memcpy(addr4.s4_addr, ip_config4.ip.v4.ip_address.bytes, sizeof(addr4.s4_addr));
75-
/* FIXME: also report gateway (net_if_ipv4_router_add()) */
76-
net_if_ipv4_addr_add(sidev->iface, &addr4, NET_ADDR_DHCP, 0);
77-
} else {
73+
if (ret) {
7874
LOG_ERR("sl_si91x_configure_ip_address(): %#04x", ret);
75+
return;
7976
}
77+
memcpy(addr4.s4_addr, ip_config4.ip.v4.ip_address.bytes, sizeof(addr4.s4_addr));
78+
/* FIXME: also report gateway (net_if_ipv4_router_add()) */
79+
net_if_ipv4_addr_add(sidev->iface, &addr4, NET_ADDR_DHCP, 0);
8080
}
8181

8282
void siwx91x_on_join_ipv6(struct siwx91x_dev *sidev)
@@ -93,19 +93,19 @@ void siwx91x_on_join_ipv6(struct siwx91x_dev *sidev)
9393
}
9494
/* FIXME: support for static IP configuration */
9595
ret = sl_si91x_configure_ip_address(&ip_config6, SL_SI91X_WIFI_CLIENT_VAP_ID);
96-
if (!ret) {
97-
ARRAY_FOR_EACH(addr6.s6_addr32, i) {
98-
addr6.s6_addr32[i] = ntohl(ip_config6.ip.v6.global_address.value[i]);
99-
}
100-
/* SiWx91x already take care of DAD and sending ND is not
101-
* supported anyway.
102-
*/
103-
net_if_flag_set(sidev->iface, NET_IF_IPV6_NO_ND);
104-
/* FIXME: also report gateway and link local address */
105-
net_if_ipv6_addr_add(sidev->iface, &addr6, NET_ADDR_AUTOCONF, 0);
106-
} else {
96+
if (ret) {
10797
LOG_ERR("sl_si91x_configure_ip_address(): %#04x", ret);
98+
return;
10899
}
100+
ARRAY_FOR_EACH(addr6.s6_addr32, i) {
101+
addr6.s6_addr32[i] = ntohl(ip_config6.ip.v6.global_address.value[i]);
102+
}
103+
/* SiWx91x already take care of DAD and sending ND is not
104+
* supported anyway.
105+
*/
106+
net_if_flag_set(sidev->iface, NET_IF_IPV6_NO_ND);
107+
/* FIXME: also report gateway and link local address */
108+
net_if_ipv6_addr_add(sidev->iface, &addr6, NET_ADDR_AUTOCONF, 0);
109109
}
110110

111111
static int siwx91x_sock_recv_sync(struct net_context *context,

0 commit comments

Comments
 (0)