On 24/03/2021 08:52, Arnout Vandecappelle wrote: > > > On 23/03/2021 17:16, Petr Štetiar wrote: >> Arnout Vandecappelle (Essensium/Mind) <[email protected]> [2021-03-23 16:23:25]: >> >> Hi, >> >>> To maintain the linked list, an additional structure ubus_msg_buf_list >>> is created. We could also have added the linked list to the ubus_msg_buf >>> struct itself, but it is not relevant in the many other uses of the >>> ubus_msg_buf struct so it would just complicate things. >> >> I've just tried to run CI pipeline[1] on this patch and got following >> complaints >> from clang static analyzer[2]: >> >> ubusd_main.c:33:3: warning: Use of memory after it is freed [unix.Malloc] >> ubus_msg_list_free(ubl); >> ^~~~~~~~~~~~~~~~~~~~~~~ >> >> ubusd_main.c:76:39: warning: Use of memory after it is freed [unix.Malloc] >> written = ubus_msg_writev(sock->fd, ubl->msg, ubl->offset); >> ^~~~~~~~ >> >> 1. https://gitlab.com/ynezz/openwrt-ubus/-/pipelines/275104805 >> 2. >> https://ynezz.gitlab.io/-/openwrt-ubus/-/jobs/1121145462/artifacts/build/scan/2021-03-23-154521-70-1/index.html > > This is a false positive. I suspect that clang doesn't see that !list_empty() > implies that the list is not empty. I'll try to rewrite using assigning to ubl > in the while loop header rather than in the body.
Duh, that doesn't work - list_first_entry doesn't give NULL if the list is empty... I'm not sure how to fix this. Any ideas? Regards, Arnout _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
