[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH 2/3] i2c_tools: Return proper errno from ioctl
From:       Olliver Schinagl <oliver+busybox () schinagl ! nl>
Date:       2023-05-12 8:35:24
Message-ID: 20230512083525.3164148-3-oliver+busybox () schinagl ! nl
[Download RAW message or body]

From: Olliver Schinagl <oliver@schinagl.nl>

We shouldn't return -1 (the default error code for the ioctl) but
instead return errno. Our big brother does the same, so we should follow
suit.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
---
 miscutils/i2c_tools.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 3a7df3b1e..166c9f6bb 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -117,7 +117,10 @@ static int32_t i2c_smbus_access(int fd, char read_write, uint8_t cmd,
 	args.size = size;
 	args.data = data;
 
-	return ioctl(fd, I2C_SMBUS, &args);
+	if (ioctl(fd, I2C_SMBUS, &args))
+		return -errno;
+
+	return 0;
 }
 
 #if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP || ENABLE_I2CDETECT
-- 
2.40.1

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic