[riot-notifications] [RIOT-OS/RIOT] Missing error check of clist_foreach(), mbox_try_put() and msg_try_send() (#15521)

HanXinrong notifications at github.com
Mon Nov 30 04:09:15 CET 2020


Hi,
As shown in the project documentation, function clist_foreach() is used to traverse clist and call function for each member. It returns a node that caused func(node, arg) to exit non-zero, or NULL on empty list or full traversal. But in the following codes, the return value is not checked.
https://github.com/RIOT-OS/RIOT/blob/c337089de58aa5c75395268f483fc5fe11ed3d64/drivers/at/at.c#L443

Moreover, at other call sites, the return values of it are checked, for instance,
https://github.com/RIOT-OS/RIOT/blob/c337089de58aa5c75395268f483fc5fe11ed3d64/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c#L652-L663
https://github.com/RIOT-OS/RIOT/blob/c337089de58aa5c75395268f483fc5fe11ed3d64/tests/unittests/tests-core/tests-core-clist.c#L252-L255
****************************************************************************************************************************************
The function mbox_try_put() is used to add message to mailbox, and returns 1 if msg could be delivered, or 0 otherwise. But at the following call sites, I think, there should be some error checks. There is no evidence to prove whether mbox were filled or not.
https://github.com/RIOT-OS/RIOT/blob/c337089de58aa5c75395268f483fc5fe11ed3d64/sys/can/conn/raw.c#L123
https://github.com/RIOT-OS/RIOT/blob/c337089de58aa5c75395268f483fc5fe11ed3d64/sys/can/conn/raw.c#L207
****************************************************************************************************************************************
Function msg_try_send() has the same problem. It returns 1 if sending a message is successful (message delivered directly or to a queue), 0 if receiver is not waiting or has a full message queue, -1 on error. As follows, there may be a lack of error checks.
https://github.com/RIOT-OS/RIOT/blob/c337089de58aa5c75395268f483fc5fe11ed3d64/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c#L258
https://github.com/RIOT-OS/RIOT/blob/c337089de58aa5c75395268f483fc5fe11ed3d64/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c#L269-L271

However, the return values of it from other call sites are checked, for example,
https://github.com/RIOT-OS/RIOT/blob/c337089de58aa5c75395268f483fc5fe11ed3d64/sys/net/gnrc/netapi/gnrc_netapi.c#L61-L66


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/issues/15521
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201129/921a8f93/attachment-0001.htm>


More information about the notifications mailing list