kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
Passing KM_SLEEP to kmem_alloc or kmem_zalloc guarantees that the return value is not NULL. Therefore any NULL pointer checking on these calls is simply unnecessary and it obfuscates the code.
Updated by Dan McDonald 2 months ago
Two ways to fix an instance of the check-for-NULL kmem_alloc(..., KM_SLEEP); antipattern:
1.) Lose the NULL check altogether.
2.) Replace KM_SLEEP with KM_NOSLEEP | KM_NORMALPRI (to prevent extraordinary reclamation efforts, assuming the caller actually copes with NULL well).
Each instance should be evaluated for which of the above is better.