diff mbox series

net: lwip: do_ping() should return CMD_RET_FAILURE when no device

Message ID 20250314084411.4165751-1-jerome.forissier@linaro.org
State Superseded
Headers show
Series net: lwip: do_ping() should return CMD_RET_FAILURE when no device | expand

Commit Message

Jerome Forissier March 14, 2025, 8:44 a.m. UTC
do_ping() expects ping_loop() to return a negative value on error, so
that it can propagate it to the caller as CMD_RET_FAILURE. This is not
the case when no ethernet device is found, so fix that.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 net/lwip/ping.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ilias Apalodimas March 14, 2025, 11:29 a.m. UTC | #1
On Fri, 14 Mar 2025 at 10:44, Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> do_ping() expects ping_loop() to return a negative value on error, so
> that it can propagate it to the caller as CMD_RET_FAILURE. This is not
> the case when no ethernet device is found, so fix that.
>
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> ---
>  net/lwip/ping.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/lwip/ping.c b/net/lwip/ping.c
> index 200a702bbb5..c586a96806d 100644
> --- a/net/lwip/ping.c
> +++ b/net/lwip/ping.c
> @@ -121,7 +121,7 @@ static int ping_loop(struct udevice *udev, const ip_addr_t *addr)
>
>         netif = net_lwip_new_netif(udev);
>         if (!netif)
> -               return CMD_RET_FAILURE;
> +               return -ENODEV;
>
>         printf("Using %s device\n", udev->name);
>
> --
> 2.43.0
>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff mbox series

Patch

diff --git a/net/lwip/ping.c b/net/lwip/ping.c
index 200a702bbb5..c586a96806d 100644
--- a/net/lwip/ping.c
+++ b/net/lwip/ping.c
@@ -121,7 +121,7 @@  static int ping_loop(struct udevice *udev, const ip_addr_t *addr)
 
 	netif = net_lwip_new_netif(udev);
 	if (!netif)
-		return CMD_RET_FAILURE;
+		return -ENODEV;
 
 	printf("Using %s device\n", udev->name);