Cynerd commented on code in PR #17278:
URL: https://github.com/apache/nuttx/pull/17278#discussion_r2490533801


##########
drivers/can/can.c:
##########
@@ -675,10 +676,25 @@ static ssize_t can_write(FAR struct file *filep, FAR 
const char *buffer,
        * CAN message at sutibal.
        */
 
-      msg    = (FAR struct can_msg_s *)&buffer[nsent];
-      nbytes = can_dlc2bytes(msg->cm_hdr.ch_dlc);
+      msg = (FAR struct can_msg_s *)&buffer[nsent];
+      if (msg->cm_hdr.ch_rtr)

Review Comment:
   Isn't that already covered by `file_writev`? That function returns `-EFAULT` 
when the buffer is `NULL` and the size is not zero. The while loop in this code 
won't be executed if the buffer has a size of zero (`buflen - sent >= 
CAN_MSGLEN(0)` is `0 - 0 >= 4`).
   
   I can add a debug assert to verify this, but there was no such check 
previously, and I suspect that unless it is called in some way directly, the 
`buffer` cannot be `NULL`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to