Messages in this thread | ![/](/images/icornerl.gif) | | Date | Tue, 2 Jan 2024 16:28:44 +0000 | From | Matthew Wilcox <> | Subject | Re: [2/2] virtiofs: Improve error handling in virtio_fs_get_tree() |
| |
On Tue, Jan 02, 2024 at 11:47:38AM +0100, Markus Elfring wrote: > > Do you consider more clarity in your argumentation? > > It is probably clear that the function call “kfree(NULL)” does not perform > data processing which is really useful for the caller. > Such a call is kept in some cases because programmers did not like to invest > development resources for its avoidance.
on the contrary, it is extremely useful for callers to not have to perform the NULL check themselves. It also mirrors userspace where free(NULL) is valid according to ISO/ANSI C, so eases the transition for programmers who are coming from userspace. It costs nothing in the implementation as it is part of the check for the ZERO_PTR.
And from a practical point of view, we can't take it out now. We can never find all the places which assume the current behaviour. So since we must keep kfree(NULL) working, we should take advantage of that to simplify users.
| ![\](/images/icornerr.gif) |