This is an automated email from the ASF dual-hosted git repository.
michallenc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f53b986fb20 can: propagate iob_tryadd_queue() failure in
can_datahandler
f53b986fb20 is described below
commit f53b986fb2042b5090fe29f8516243b67aafc6e1
Author: OceanfromXiaomi <[email protected]>
AuthorDate: Mon Aug 25 11:15:49 2025 +0800
can: propagate iob_tryadd_queue() failure in can_datahandler
The can_datahandler() function calls iob_tryadd_queue() to enqueue
received CAN data. Since iob_tryadd_queue() may return a negative
value on failure, the error was previously not properly handled.
Update can_datahandler() to propagate the return value so callers
can detect and handle queueing failures correctly.
Signed-off-by: zhaohaiyang1 <[email protected]>
---
net/can/can.h | 8 ++++----
net/can/can_callback.c | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/can/can.h b/net/can/can.h
index 26ce489d4f1..3a7a50165d0 100644
--- a/net/can/can.h
+++ b/net/can/can.h
@@ -254,8 +254,8 @@ uint32_t can_callback(FAR struct net_driver_s *dev,
* conn - A pointer to the CAN connection structure
*
* Returned Value:
- * The number of bytes actually buffered is returned. This will be either
- * zero or equal to buflen; partial packets are not buffered.
+ * The number of bytes actually buffered is returned. This will be
+ * negative or zero or equal to buflen; partial packets are not buffered.
*
* Assumptions:
* - The caller has checked that CAN_NEWDATA is set in flags and that is no
@@ -264,8 +264,8 @@ uint32_t can_callback(FAR struct net_driver_s *dev,
*
****************************************************************************/
-uint16_t can_datahandler(FAR struct net_driver_s *dev,
- FAR struct can_conn_s *conn);
+int can_datahandler(FAR struct net_driver_s *dev,
+ FAR struct can_conn_s *conn);
/****************************************************************************
* Name: can_recvmsg
diff --git a/net/can/can_callback.c b/net/can/can_callback.c
index 6d31fda2152..0aac77cd6f4 100644
--- a/net/can/can_callback.c
+++ b/net/can/can_callback.c
@@ -67,7 +67,7 @@ can_data_event(FAR struct net_driver_s *dev, FAR struct
can_conn_s *conn,
uint32_t flags)
{
int buflen = dev->d_len;
- uint16_t recvlen;
+ int recvlen;
uint32_t ret;
#ifdef CONFIG_NET_TIMESTAMP
@@ -193,8 +193,8 @@ uint32_t can_callback(FAR struct net_driver_s *dev,
*
****************************************************************************/
-uint16_t can_datahandler(FAR struct net_driver_s *dev,
- FAR struct can_conn_s *conn)
+int can_datahandler(FAR struct net_driver_s *dev,
+ FAR struct can_conn_s *conn)
{
FAR struct iob_s *iob = dev->d_iob;
int ret = 0;