Page MenuHomeFreeBSD

linuxkpi: Fix llist_entry
Needs ReviewPublic

Authored by manu on Aug 22 2022, 8:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 11:42 PM
Unknown Object (File)
Wed, Oct 1, 6:22 PM
Unknown Object (File)
Sat, Sep 27, 5:30 PM
Unknown Object (File)
Sep 4 2025, 1:15 PM
Unknown Object (File)
Sep 4 2025, 5:14 AM
Unknown Object (File)
Sep 4 2025, 2:35 AM
Unknown Object (File)
Jul 10 2025, 9:30 AM
Unknown Object (File)
Jun 15 2025, 1:25 AM

Details

Reviewers
None
Group Reviewers
linuxkpi
Summary

llist_entry(NULL) must not return NULL, it needs to wrap around
and return NULL minus the offset.

the iterators stop when the offset added back to the result of
llist_entry() is NULL

they test that the first node is not NULL or that the next pointer
stored in a previous iteration of the loop is not NULL

OpenBSD commit: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/dev/pci/drm/include/linux/llist.h?rev=1.3&content-type=text/x-cvsweb-markup

Reported by: jsg@OpenBSD.org
Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

manu requested review of this revision.Aug 22 2022, 8:32 AM
hselasky added inline comments.
sys/compat/linuxkpi/common/include/linux/llist.h
91

Is it more clean to write:

(pos) != llist_entry(NULL, __typeof(*pos), member)
92

While at it change:

pos->member.next

into:

(pos)->member.next
97

Ditto?

sys/compat/linuxkpi/common/include/linux/llist.h
91

Why that ?
I find your way more confusing.

sys/compat/linuxkpi/common/include/linux/llist.h
91

Because container_of() is doing some type checking at least, while (char *) is a pure cast.

I don't have any strong opinion here.