This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch releases/12.12
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/releases/12.12 by this push:
new f4b40680274 drivers/can/can.c: fix broken O_NONBLOCK
f4b40680274 is described below
commit f4b406802741a0dcf1d81bcc40f1b71abde3746c
Author: raiden00pl <[email protected]>
AuthorDate: Sun Dec 7 11:28:17 2025 +0100
drivers/can/can.c: fix broken O_NONBLOCK
O_NONBLOCK open mode was broken since
https://github.com/apache/nuttx/pull/17360
MIN() comapres signed value (int) with unsigned value (size_t) which causes
an unexpected return value when ret is negative
Signed-off-by: raiden00pl <[email protected]>
---
drivers/can/can.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/can/can.c b/drivers/can/can.c
index d3fb83151a3..a88e7578455 100644
--- a/drivers/can/can.c
+++ b/drivers/can/can.c
@@ -518,7 +518,7 @@ return_with_irqdisabled:
/* ret can be more than buflen due to roundup, so return at most buflen */
- return ret ? MIN(ret, buflen) : -EMSGSIZE;
+ return ret ? MIN(ret, (ssize_t)buflen) : -EMSGSIZE;
}
/****************************************************************************
@@ -744,7 +744,7 @@ static ssize_t can_write(FAR struct file *filep, FAR const
char *buffer,
* can be more due to roundup.
*/
- ret = MIN(nsent, buflen);
+ ret = MIN(nsent, (ssize_t)buflen);
return_with_irqdisabled:
leave_critical_section(flags);