mirror of
https://github.com/apache/nuttx.git
synced 2026-05-24 07:46:16 +08:00
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 <zhaohaiyang1@xiaomi.com>
This commit is contained in:
committed by
Michal Lenc
parent
e3403709f8
commit
f53b986fb2
+4
-4
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user