]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
linuxkpi: Accept NULL as a value in `linux_xarray`
authorJean-Sébastien Pédron <dumbbell@FreeBSD.org>
Sat, 11 Feb 2023 10:12:08 +0000 (11:12 +0100)
committerJean-Sébastien Pédron <dumbbell@FreeBSD.org>
Thu, 16 Feb 2023 11:55:20 +0000 (12:55 +0100)
commit895d286a36cf70fa527538ca3c9a1a545f81a9cd
treec4943e4282c1673f1b42158f026be6df42f9aa1b
parent708dc3db0417b2e53d70e88cabb48a3018b632f3
linuxkpi: Accept NULL as a value in `linux_xarray`

Linux' XArray allows to store a NULL pointer as a value. `xa_load()`
would return NULL for both an unused index and an index set to NULL. But
it impacts `xa_alloc()` which needs to find the next available index.

However, our implementation relies on a radix tree (see `linux_radix.c`)
which does not accept NULL pointers as values. I'm not sure if this is a
limitation or a feature, so to work around this, a NULL value is
replaced by `NULL_VALUE`, an unlikely address, when we pass it to
linux_radix.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D38543

(cherry picked from commit 3102ea3b15b6c3ed1ea50716d65980b680375ebc)
sys/compat/linuxkpi/common/src/linux_xarray.c