diff mbox series

[U-Boot,v3,01/11] sandbox: eth-raw: Correct valid socket test in send/recv

Message ID 20180702194754.1955-2-joe.hershberger@ni.com
State Accepted
Commit 97367df
Delegated to: Joe Hershberger
Headers show
Series sandbox: net: Fix sandbox eth drivers | expand

Commit Message

Joe Hershberger July 2, 2018, 7:47 p.m. UTC
In open, the socket is correctly checked to be -1 in the error case.
In send and recv, we checked for 0, but that is a valid socket number.

Correct this by checking for -1 as a bad socket everywhere.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/eth-raw-os.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Joe Hershberger July 26, 2018, 7:15 p.m. UTC | #1
Hi Joe,

https://patchwork.ozlabs.org/patch/938157/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
index e054a0702a..61f23ed210 100644
--- a/arch/sandbox/cpu/eth-raw-os.c
+++ b/arch/sandbox/cpu/eth-raw-os.c
@@ -156,7 +156,7 @@  int sandbox_eth_raw_os_send(void *packet, int length,
 	int retval;
 	struct udphdr *udph = packet + sizeof(struct iphdr);
 
-	if (!priv->sd || !priv->device)
+	if (priv->sd < 0 || !priv->device)
 		return -EINVAL;
 
 	/*
@@ -221,7 +221,7 @@  int sandbox_eth_raw_os_recv(void *packet, int *length,
 	int retval;
 	int saddr_size;
 
-	if (!priv->sd || !priv->device)
+	if (priv->sd < 0 || !priv->device)
 		return -EINVAL;
 	saddr_size = sizeof(struct sockaddr);
 	retval = recvfrom(priv->sd, packet, 1536, 0,