From: Michael Vogt Date: Fri, 27 Mar 2026 09:44:03 +0000 (+0100) Subject: coccinelle: generalize pidref_is_set() to `=~ _is_set()` X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bf2d68433de56f679bfed031023ebdcd6797e034;p=thirdparty%2Fsystemd.git coccinelle: generalize pidref_is_set() to `=~ _is_set()` Our coccinelle/check-pointer-deref.cocci checker has a special case for `assert(pidref_is_set(param))`. It turns out we can generalize this and catch the following: - iovec_is_set - sd_dhcp_duid_is_set - sd_dhcp_client_id_is_set --- diff --git a/coccinelle/check-pointer-deref.cocci b/coccinelle/check-pointer-deref.cocci index e2376a314c5..dd058fae3bf 100644 --- a/coccinelle/check-pointer-deref.cocci +++ b/coccinelle/check-pointer-deref.cocci @@ -13,6 +13,7 @@ */ @@ identifier fn, param; +identifier is_set =~ "_is_set$"; type T; position p; @@ @@ -25,10 +26,12 @@ fn(..., T *param, ...) { when != assert_return(param, ...) when != ASSERT_PTR(param) when != POINTER_MAY_BE_NULL(param) - /* NULL-safe helpers used commonly enough in assert() to warrant inclusion - * here. For less common cases, use POINTER_MAY_BE_NULL(param) instead of - * extending this list. */ - when != assert(pidref_is_set(param)) + /* Any foo_is_set(param) guard implies param != NULL, since all *_is_set() + * helpers in systemd return false for NULL input. Note the is_set regex + * in identifier. */ + when != assert(is_set(param)) + when != assert_return(is_set(param), ...) + when != \( is_set(param) \) when != \( param == NULL \| param != NULL \| !param \) * *param@p ... diff --git a/src/boot/initrd.c b/src/boot/initrd.c index b8086ac6337..d8cbe7deed4 100644 --- a/src/boot/initrd.c +++ b/src/boot/initrd.c @@ -74,7 +74,6 @@ EFI_STATUS initrd_register( EFI_HANDLE handle; struct initrd_loader *loader; - POINTER_MAY_BE_NULL(initrd); assert(ret_initrd_handle); /* If no initrd is specified we'll not install any. This avoids registration of the protocol for that