mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
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 <raiden00@railab.me>
This commit is contained in:
+2
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user