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:
raiden00pl
2025-12-07 11:28:17 +01:00
committed by Matteo Golin
parent a87ad98343
commit 8c8a7484ab
+2 -2
View File
@@ -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);