occam25 commented on code in PR #15715:
URL: https://github.com/apache/nuttx/pull/15715#discussion_r1934226080


##########
net/can/can_callback.c:
##########
@@ -236,6 +234,7 @@ uint16_t can_datahandler(FAR struct net_driver_s *dev,
   else
     {
       nerr("ERROR: Failed to queue the I/O buffer chain: %d\n", ret);
+      ret = 0;

Review Comment:
   This was actually a bug. This function returns an uint16_t as the number of 
bytes actually buffered, but the call to iob_tryadd_queue (line 218)  returns 
an int and, if it fails, it returns a negative value. In that case, 
can_datahandler return value is cast to an unsigned value as if it would had 
buffered many bytes. 
   Setting the returning value to zero when iob_tryadd_queue fails reflects the 
actual meaning that no bytes have been buffered



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to