Should I use "NULL" in kernel code?
Posted: Wed Jul 31, 2024 11:47 am
Hi,
In userspace programming I can safely use NULL (0) to indicate invalid pointer value. Because accessing address zero causes pagee fault.
In kernel should I still use NULL for invalid pointer value? Zero for invalid physical address and invalid page frame number?
It's possible that I want to use data from address zero, like allocating the first physical page, or access data dynamically mapped at address zero.
So for kernel, NULL and 0 shouldn't be seen as invalid address, right? What's the proper value for an invalid pointer? invalid physical address? Or am I just over complicating things?
Thanks
In userspace programming I can safely use NULL (0) to indicate invalid pointer value. Because accessing address zero causes pagee fault.
In kernel should I still use NULL for invalid pointer value? Zero for invalid physical address and invalid page frame number?
It's possible that I want to use data from address zero, like allocating the first physical page, or access data dynamically mapped at address zero.
So for kernel, NULL and 0 shouldn't be seen as invalid address, right? What's the proper value for an invalid pointer? invalid physical address? Or am I just over complicating things?
Thanks