From 0b8f7d85bcac5aedcc9db8170b640b4b70543c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Pouiller?= Date: Thu, 22 May 2025 14:19:18 +0200 Subject: [PATCH] drivers: wifi: siwx91x: Uniformize error management MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- drivers/wifi/siwx91x/siwx91x_wifi_socket.c | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/wifi/siwx91x/siwx91x_wifi_socket.c b/drivers/wifi/siwx91x/siwx91x_wifi_socket.c index 8257e22984b..b84a436051f 100644 --- a/drivers/wifi/siwx91x/siwx91x_wifi_socket.c +++ b/drivers/wifi/siwx91x/siwx91x_wifi_socket.c @@ -70,13 +70,13 @@ void siwx91x_on_join_ipv4(struct siwx91x_dev *sidev) } /* FIXME: support for static IP configuration */ ret = sl_si91x_configure_ip_address(&ip_config4, SL_SI91X_WIFI_CLIENT_VAP_ID); - if (!ret) { - memcpy(addr4.s4_addr, ip_config4.ip.v4.ip_address.bytes, sizeof(addr4.s4_addr)); - /* FIXME: also report gateway (net_if_ipv4_router_add()) */ - net_if_ipv4_addr_add(sidev->iface, &addr4, NET_ADDR_DHCP, 0); - } else { + if (ret) { LOG_ERR("sl_si91x_configure_ip_address(): %#04x", ret); + return; } + memcpy(addr4.s4_addr, ip_config4.ip.v4.ip_address.bytes, sizeof(addr4.s4_addr)); + /* FIXME: also report gateway (net_if_ipv4_router_add()) */ + net_if_ipv4_addr_add(sidev->iface, &addr4, NET_ADDR_DHCP, 0); } void siwx91x_on_join_ipv6(struct siwx91x_dev *sidev) @@ -93,19 +93,19 @@ void siwx91x_on_join_ipv6(struct siwx91x_dev *sidev) } /* FIXME: support for static IP configuration */ ret = sl_si91x_configure_ip_address(&ip_config6, SL_SI91X_WIFI_CLIENT_VAP_ID); - if (!ret) { - ARRAY_FOR_EACH(addr6.s6_addr32, i) { - addr6.s6_addr32[i] = ntohl(ip_config6.ip.v6.global_address.value[i]); - } - /* SiWx91x already take care of DAD and sending ND is not - * supported anyway. - */ - net_if_flag_set(sidev->iface, NET_IF_IPV6_NO_ND); - /* FIXME: also report gateway and link local address */ - net_if_ipv6_addr_add(sidev->iface, &addr6, NET_ADDR_AUTOCONF, 0); - } else { + if (ret) { LOG_ERR("sl_si91x_configure_ip_address(): %#04x", ret); + return; } + ARRAY_FOR_EACH(addr6.s6_addr32, i) { + addr6.s6_addr32[i] = ntohl(ip_config6.ip.v6.global_address.value[i]); + } + /* SiWx91x already take care of DAD and sending ND is not + * supported anyway. + */ + net_if_flag_set(sidev->iface, NET_IF_IPV6_NO_ND); + /* FIXME: also report gateway and link local address */ + net_if_ipv6_addr_add(sidev->iface, &addr6, NET_ADDR_AUTOCONF, 0); } static int siwx91x_sock_recv_sync(struct net_context *context,