Skip to content

Commit

Permalink
bug fix: can_datahandler wrong return value
Browse files Browse the repository at this point in the history
can_datahandler returns an unsigned value that represent the
number of bytes actually bufffered, but the call to iob_tryadd_queue
returns a negative value when it fails so that value can't be used as
can_datahandler return value because it is interpreted as unsigned so
a big number is wrongly returned when iob_tryadd_queue fails.

The fix is just setting the return value to zero when iob_tryadd_queue
fails, reflecting the actual meaning that no bytes have been buffered.
  • Loading branch information
occam25 committed Jan 30, 2025
1 parent cd142d4 commit 982b48c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/can/can_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,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;
goto errout;
}

Expand Down

0 comments on commit 982b48c

Please sign in to comment.