treewide: switch to __nonnull_args() macro
Subsystems (13)
cover treewide: switch to __nonnull_args() macro
Commit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the __nonnull_args() macro to wrap the raw compiler attribute, keeping the attribute's quirks in one place rather than open-coded at every call site.
This series replaces the remaining open-coded __attribute__((nonnull)) users with __nonnull_args() to standardize nonnull attribute usage across the tree.
Each patch can be applied separately by the respective maintainers. The only dependency is kernel-doc: the string and lib/list_sort patches need patch 1 ("docs: xforms_lists: support __nonnull_args()") in the same release, otherwise strends() and list_sort() drop out of the generated documentation.
Latest Sparse release could not properly parse __nonnull_args() without arguments. Fix was proposed [1] and merged, but until updated version of Sparse will reach wide masses it might trip on __nonnull_args() without arguments.
There are few more instances of __attribute__((nonnull)) usages left in the tools subdirectory, they are perf related copied files and can (should?) be updated separately after this patchset lands.
Build-tested allmodconfig with GCC 11.5.0 and clang 22.1.8.
[1]: https://lore.kernel.org/all/[email protected]/
Dmitry Ilvokhin (10):
docs: xforms_lists: support __nonnull_args()
string: Switch to __nonnull_args() macro lib/list_sort: Switch to __nonnull_args() macro
xarray: switch to __nonnull_args() macro drm/i915: switch to __nonnull_args() macro drm/amdgpu: switch to __nonnull_args() macro drm/gem: Switch to __nonnull_args() macro
leds: pwm: Switch to __nonnull_args() macro
soc: aspeed: lpc-snoop: Switch to __nonnull_args() macro
checkpatch: suggest nonnull attribute conversion
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_object.h | 4 ++-- drivers/gpu/drm/i915/i915_request.h | 4 ++-- drivers/leds/leds-pwm.c | 2 +- drivers/soc/aspeed/aspeed-lpc-snoop.c | 4 ++-- include/drm/drm_gem.h | 2 +- include/linux/list_sort.h | 4 ++-- include/linux/string.h | 2 +- include/linux/xarray.h | 4 ++-- lib/list_sort.c | 6 +++--- scripts/checkpatch.pl | 3 +++ tools/include/linux/compiler.h | 4 ++++ tools/lib/python/kdoc/xforms_lists.py | 1 + 13 files changed, 25 insertions(+), 17 deletions(-)
base-commit: 6b4b543fa18757297ac756a6fe6e64f506b7844a
Signature · 1 line
2.53.0-Meta
PATCH 1/10 docs: xforms_lists: support __nonnull_args()
Avoid kernel-doc warnings by supporting __nonnull_args() as a function transform.
This is a preparatory change for the treewide migration from __attribute__((nonnull)) to __nonnull_args() macro.
--- tools/lib/python/kdoc/xforms_lists.py | 1 + 1 file changed, 1 insertion(+)
tools/lib/python/kdoc/xforms_lists.py +1 -0
@@ -108,6 +108,7 @@ class CTransforms: (CMatch("__attribute__"), ""), (CMatch("STATIC_IFN_KUNIT"), ""), (CMatch("INLINE_IFN_KUNIT"), ""), + (CMatch("__nonnull_args"), ""), # # HACK: this is similar to process_export() hack. It is meant to
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 01/10] docs: xforms_lists: support __nonnull_args()
Sashiko has reviewed this patch and found no issues.
Quoted 7 lines
Avoid kernel-doc warnings by supporting
__nonnull_args()as a function transform.This is a preparatory change for the treewide migration from __attribute__((nonnull)) to
__nonnull_args()macro.Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH 2/10 string: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinCommit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the macro __nonnull_args() to wrap raw compiler attribute.
Replace __attribute__((nonnull)) with __nonnull_args() to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
--- include/linux/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/string.h +1 -1
@@ -587,7 +587,7 @@ static inline bool strstarts(const char *str, const char *prefix)* Returns: * True if @str ends with @suffix. False in all other cases. */ -static inline bool __attribute__((nonnull (1 ,2 ))) +static inline bool __nonnull_args(1, 2) strends(const char *str, const char *suffix) { unsigned int str_len = strlen(str), suffix_len = strlen(suffix);
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 02/10] string: Switch to __nonnull_args() macro
Sashiko has reviewed this patch and found no issues.
Quoted 11 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH 02/10] string: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinQuoted 9 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 3/10 lib/list_sort: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinCommit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the macro __nonnull_args() to wrap raw compiler attribute.
Replace __attribute__((nonnull)) with __nonnull_args() to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
Add spaces after the commas in the __nonnull_args() argument list to follow the usual coding style (according to checkpatch).
--- include/linux/list_sort.h | 4 ++-- lib/list_sort.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
include/linux/list_sort.h +2 -2
@@ -6,9 +6,9 @@struct list_head ; -typedef int __attribute__((nonnull(2,3))) (*list_cmp_func_t)(void *, +typedef int __nonnull_args(2, 3) (*list_cmp_func_t)(void *,const struct list_head *,const struct list_head *); -__attribute__((nonnull (2 ,3 ))) +__nonnull_args(2, 3)void list_sort (void *priv,struct list_head *head,list_cmp_func_t cmp);#endif
lib/list_sort.c +3 -3
@@ -9,7 +9,7 @@* to chaining of merge() calls: null-terminated, no reserved or * sentinel head node, "prev" links not maintained. */ -__attribute__((nonnull (2 ,3 ,4 ))) +__nonnull_args(2, 3, 4)static struct list_head *merge (void *priv,list_cmp_func_t cmp,struct list_head *a,struct list_head *b) {
@@ -45,7 +45,7 @@ static struct list_head *merge(void *priv, list_cmp_func_t cmp,* prev-link restoration pass, or maintaining the prev links * throughout. */ -__attribute__((nonnull (2 ,3 ,4 ,5 ))) +__nonnull_args(2, 3, 4, 5)static void merge_final (void *priv,list_cmp_func_t cmp,struct list_head *head,struct list_head *a,struct list_head *b) {
@@ -175,7 +175,7 @@ static void merge_final(void *priv, list_cmp_func_t cmp, struct list_head *head,* of size 2^k varies from 2^(k-1) (cases 3 and 5 when x == 0) to * 2^(k+1) - 1 (second merge of case 5 when x == 2^(k-1) - 1). */ -__attribute__((nonnull (2 ,3 ))) +__nonnull_args(2, 3)void list_sort (void *priv,struct list_head *head,list_cmp_func_t cmp) {struct list_head *list = head->next, *pending =NULL ;
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 03/10] lib/list_sort: Switch to __nonnull_args() macro
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
Quoted 5 lines
Add spaces after the commas in the
__nonnull_args()argument list to follow the usual coding style (according to checkpatch).Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH 03/10] lib/list_sort: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinQuoted 5 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.
Quoted 7 lines
Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Add spaces after the commas in the
__nonnull_args()argument list to follow the usual coding style (according to checkpatch).
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 4/10 xarray: switch to __nonnull_args() macro
In reply to Dmitry IlvokhinCommit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the macro __nonnull_args() to wrap raw compiler attribute.
Replace __attribute__((nonnull)) with __nonnull_args() to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
tools/testing/shared/linux/xarray.h directly includes the kernel's include/linux/xarray.h, which now uses __nonnull_args(). The macro is not defined under tools/, breaking test builds.
Define __nonnull_args() in tools/include/linux/compiler.h.
--- include/linux/xarray.h | 4 ++-- tools/include/linux/compiler.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)
include/linux/xarray.h +2 -2
@@ -361,9 +361,9 @@ bool xa_get_mark(struct xarray *, unsigned long index, xa_mark_t);void xa_set_mark (struct xarray *,unsigned long index,xa_mark_t );void xa_clear_mark (struct xarray *,unsigned long index,xa_mark_t );void *xa_find (struct xarray *xa,unsigned long *index, -unsigned long max,xa_mark_t ) __attribute__((nonnull (2 ))); +unsigned long max,xa_mark_t )__nonnull_args (2 );void *xa_find_after (struct xarray *xa,unsigned long *index, -unsigned long max,xa_mark_t ) __attribute__((nonnull (2 ))); +unsigned long max,xa_mark_t )__nonnull_args (2 );unsigned int xa_extract (struct xarray *,void **dst,unsigned long start,unsigned long max,unsigned int n,xa_mark_t );void xa_destroy (struct xarray *);
tools/include/linux/compiler.h +4 -0
@@ -68,6 +68,10 @@#define __naked __attribute__((__naked__))#endif +#ifndef __nonnull_args +#define __nonnull_args(x...) __attribute__((__nonnull__(x))) +#endif +/* Are two types/vars the same type (ignoring qualifiers)? */ #ifndef __same_type# define __same_type (a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 04/10] xarray: switch to __nonnull_args() macro
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
Quoted 8 lines
tools/testing/shared/linux/xarray.hdirectly includes the kernel'sinclude/linux/xarray.h, which now uses__nonnull_args(). The macro is not defined undertools/, breaking test builds.Define
__nonnull_args()intools/include/linux/compiler.h.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH 5/10 drm/i915: switch to __nonnull_args() macro
In reply to Dmitry IlvokhinCommit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the macro __nonnull_args() to wrap raw compiler attribute.
Replace __attribute__((nonnull)) with __nonnull_args() to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
--- drivers/gpu/drm/i915/gem/i915_gem_object.h | 4 ++-- drivers/gpu/drm/i915/i915_request.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.h +2 -2
@@ -127,7 +127,7 @@ __deprecatedstruct drm_gem_object *drm_gem_object_lookup (struct drm_file *file,u32 handle); -__attribute__((nonnull)) +__nonnull_args()static inline struct drm_i915_gem_object *i915_gem_object_get (struct drm_i915_gem_object *obj) {
@@ -135,7 +135,7 @@ i915_gem_object_get(struct drm_i915_gem_object *obj)return obj; } -__attribute__((nonnull)) +__nonnull_args()static inline void i915_gem_object_put (struct drm_i915_gem_object *obj) {
drivers/gpu/drm/i915/i915_request.h +2 -2
@@ -437,12 +437,12 @@ void i915_request_cancel(struct i915_request *rq, int error); long i915_request_wait_timeout(struct i915_request *rq, unsigned int flags, long timeout) - __attribute__((nonnull (1 ))); + __nonnull_args(1); long i915_request_wait(struct i915_request *rq, unsigned int flags, long timeout) - __attribute__((nonnull (1 ))); + __nonnull_args(1);#define I915_WAIT_INTERRUPTIBLE BIT(0)#define I915_WAIT_PRIORITY BIT(1)/* small priority bump for the request */ #define I915_WAIT_ALL BIT(2)/* used by i915_gem_object_wait() */
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 05/10] drm/i915: switch to __nonnull_args() macro
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
Re: [PATCH 05/10] drm/i915: switch to __nonnull_args() macro
In reply to Dmitry IlvokhinQuoted 8 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 05/10] drm/i915: switch to __nonnull_args() macro
In reply to Dmitry IlvokhinQuoted 10 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Quoted 46 lines
--- drivers/gpu/drm/i915/gem/i915_gem_object.h | 4 ++-- drivers/gpu/drm/i915/i915_request.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_object.h +2
-2@@ -127,7 +127,7 @@ __deprecatedstruct drm_gem_object *drm_gem_object_lookup (struct drm_file *file,u32 handle); -__attribute__((nonnull)) +__nonnull_args()static inline struct drm_i915_gem_object *i915_gem_object_get (struct drm_i915_gem_object *obj) {@@ -135,7 +135,7 @@ i915_gem_object_get(struct drm_i915_gem_object *obj)return obj; } -__attribute__((nonnull)) +__nonnull_args()static inline void i915_gem_object_put (struct drm_i915_gem_object *obj) {drivers/gpu/drm/i915/i915_request.h +2
-2@@ -437,12 +437,12 @@ void i915_request_cancel(struct i915_request *rq, int error); long i915_request_wait_timeout(struct i915_request *rq, unsigned int flags, long timeout) - __attribute__((nonnull (1 ))); + __nonnull_args(1); long i915_request_wait(struct i915_request *rq, unsigned int flags, long timeout) - __attribute__((nonnull (1 ))); + __nonnull_args(1);#define I915_WAIT_INTERRUPTIBLE BIT(0)#define I915_WAIT_PRIORITY BIT(1)/* small priority bump for the request */ #define I915_WAIT_ALL BIT(2)/* used by i915_gem_object_wait() */
Signature · 1 line
Jani Nikula, Intel
Re: [PATCH 05/10] drm/i915: switch to __nonnull_args() macro
In reply to Dmitry IlvokhinHi Dmitry,
Quoted 10 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Thanks,
Andi
Jani Nikula
maintainerRe: [PATCH 05/10] drm/i915: switch to __nonnull_args() macro
Quoted 7 lines · Andi Shyti
Hi Dmitry,
Quoted 4 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.
Quoted 8 lines
Quoted 6 lines
Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>Reviewed-by Andi Shyti <[email protected]>
Pushed this patch to drm-intel-next, thanks for the patch and review.
BR,
Jani.
Signature · 1 line
Jani Nikula, Intel
PATCH 6/10 drm/amdgpu: switch to __nonnull_args() macro
In reply to Dmitry IlvokhinCommit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the macro __nonnull_args() to wrap raw compiler attribute.
Replace __attribute__((nonnull)) with __nonnull_args() to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -307,7 +307,7 @@ static int amdgpu_ttm_map_buffer(struct amdgpu_ttm_buffer_entity *entity,* move and different for a BO to BO copy. * */ -__attribute__((nonnull)) +__nonnull_args() static int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev, struct amdgpu_ttm_buffer_entity *entity, const struct amdgpu_copy_mem *src,
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 06/10] drm/amdgpu: switch to __nonnull_args() macro
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
PATCH 7/10 drm/gem: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinCommit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the macro __nonnull_args() to wrap raw compiler attribute.
Replace __attribute__((nonnull)) with __nonnull_args() to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
--- include/drm/drm_gem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_gem.h +1 -1
@@ -566,7 +566,7 @@ static inline void drm_gem_object_get(struct drm_gem_object *obj)kref_get (&obj->refcount); } -__attribute__((nonnull)) +__nonnull_args()static inline void __drm_gem_object_put (struct drm_gem_object *obj) {
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 07/10] drm/gem: Switch to __nonnull_args() macro
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
Re: [PATCH 07/10] drm/gem: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinHi Dmitry,
Quoted 10 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Thanks,
Andi
Re: [PATCH 07/10] drm/gem: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinHi
Am 28.10.26 um 09:19 schrieb Dmitry Ilvokhin:
Quoted 10 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Should gem.h now include <linux/compiler_attributes.h> ?
Best regards
Thomas
Quoted 17 lines
--- include/drm/drm_gem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/drm/drm_gem.h +1
-1@@ -566,7 +566,7 @@ static inline void drm_gem_object_get(struct drm_gem_object *obj)kref_get (&obj->refcount); } -__attribute__((nonnull)) +__nonnull_args()static inline void __drm_gem_object_put (struct drm_gem_object *obj) {
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
Re: [PATCH 07/10] drm/gem: Switch to __nonnull_args() macro
Quoted 2 lines · Thomas Zimmermann
Should
gem.hnow include <linux/compiler_attributes.h> ?
No, it should be included for you (unless you are doing something custom with the compiler flags etc.).
I hope that helps!
Cheers,
Miguel
Re: [PATCH 07/10] drm/gem: Switch to __nonnull_args() macro
Quoted 6 lines · Miguel Ojeda
Quoted 2 lines · Thomas Zimmermann
Should
gem.hnow include <linux/compiler_attributes.h> ?No, it should be included for you (unless you are doing something custom with the compiler flags etc.).
Just to add a bit more colour to Miguel's reply.
I believe idea behind include/linux/compiler_attributes.h is to make attribute wrappers as simple and transparent to use as native compiler attributes. In particular, this means they should be available in every kernel compilation unit without any additional effort.
For this reason, all the nessesary plumbing is handled at the build machinery level (see scripts/Makefile.lib:171), where '-include' compiler flag is used to pull in include/linux/compiler_types.h, which in turn pulls include/linux/compiler_attributes.h.
Re: [PATCH 07/10] drm/gem: Switch to __nonnull_args() macro
Quoted 15 lines · Dmitry Ilvokhin
Quoted 6 lines · Miguel Ojeda
Quoted 2 lines · Thomas Zimmermann
Should
gem.hnow include <linux/compiler_attributes.h> ?No, it should be included for you (unless you are doing something custom with the compiler flags etc.).
Just to add a bit more colour to Miguel's reply.
I believe idea behind
include/linux/compiler_attributes.his to make attribute wrappers as simple and transparent to use as native compiler attributes. In particular, this means they should be available in every kernel compilation unit without any additional effort.
Quoted 4 lines
For this reason, all the nessesary plumbing is handled at the build machinery level (see
scripts/Makefile.lib:171), where '-include' compiler flag is used to pull ininclude/linux/compiler_types.h, which in turn pullsinclude/linux/compiler_attributes.h.
Ah, TIL! Please, discard my comment then. Perhaps we need to clean up all headers that pull compiler_types/compile_attributes directly (the same way we do for kconfig.h).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 07/10] drm/gem: Switch to __nonnull_args() macro
In reply to Miguel OjedaQuoted 6 lines · Miguel Ojeda
Quoted 2 lines · Thomas Zimmermann
Should
gem.hnow include <linux/compiler_attributes.h> ?No, it should be included for you (unless you are doing something custom with the compiler flags etc.).
Usually it comes to the mere drivers via types.h, in rare cases (usually some more generic library headers, we do better granularity as it affects the almost entire kernel. Just double check that types.h is explicitly included.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Thomas Zimmermann
maintainerRe: [PATCH 07/10] drm/gem: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinAm 28.10.26 um 09:19 schrieb Dmitry Ilvokhin:
Quoted 10 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
I've added this patch to drm-misc-next
Quoted 17 lines
--- include/drm/drm_gem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/drm/drm_gem.h +1
-1@@ -566,7 +566,7 @@ static inline void drm_gem_object_get(struct drm_gem_object *obj)kref_get (&obj->refcount); } -__attribute__((nonnull)) +__nonnull_args()static inline void __drm_gem_object_put (struct drm_gem_object *obj) {
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
PATCH 8/10 leds: pwm: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinCommit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the macro __nonnull_args() to wrap raw compiler attribute.
Replace __attribute__((nonnull)) with __nonnull_args() to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
--- drivers/leds/leds-pwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-pwm.c +1 -1
@@ -80,7 +80,7 @@ static int led_pwm_default_brightness_get(struct fwnode_handle *fwnode,return default_brightness; } -__attribute__((nonnull)) +__nonnull_args()static int led_pwm_add (struct device *dev,struct led_pwm_priv *priv,struct led_pwm *led,struct fwnode_handle *fwnode) {
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 08/10] leds: pwm: Switch to __nonnull_args() macro
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Re: [PATCH 08/10] leds: pwm: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinQuoted 8 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: (subset) [PATCH 08/10] leds: pwm: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinQuoted 9 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.[...]
Applied, thanks!
[08/10] leds: pwm: Switch to __nonnull_args() macro
commit: 687615faae92e36a2b6c5ab0d007751e8e88a645
--
Lee Jones [李琼斯]
PATCH 9/10 soc: aspeed: lpc-snoop: Switch to __nonnull_args() macro
In reply to Dmitry IlvokhinCommit 22302af28d3f ("cleanup: Annotate guard constructors with nonnull") added the macro __nonnull_args() to wrap raw compiler attribute.
Replace __attribute__((nonnull)) with __nonnull_args() to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.
--- drivers/soc/aspeed/aspeed-lpc-snoop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/aspeed/aspeed-lpc-snoop.c +2 -2
@@ -226,7 +226,7 @@ static int aspeed_lpc_snoop_config_irq(struct aspeed_lpc_snoop *lpc_snoop,return 0 ; } -__attribute__((nonnull)) +__nonnull_args() static int aspeed_lpc_enable_snoop(struct device *dev, struct aspeed_lpc_snoop *lpc_snoop, struct aspeed_lpc_snoop_channel *channel,
@@ -279,7 +279,7 @@ static int aspeed_lpc_enable_snoop(struct device *dev,return rc; } -__attribute__((nonnull)) +__nonnull_args()static void aspeed_lpc_disable_snoop (struct aspeed_lpc_snoop *lpc_snoop,struct aspeed_lpc_snoop_channel *channel) {
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 09/10] soc: aspeed: lpc-snoop: Switch to __nonnull_args() macro
Sashiko has reviewed this patch and found no issues.
Quoted 10 lines
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the macro__nonnull_args()to wrap raw compiler attribute.Replace __attribute__((nonnull)) with
__nonnull_args()to standardize nonnull attribute usage across the tree and keep the attribute's quirks in one place rather than open-coded at every call site.Suggested-by Miguel Ojeda <[email protected]>Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
PATCH 10/10 checkpatch: suggest nonnull attribute conversion
In reply to Dmitry IlvokhinThe kernel provides the __nonnull_args() macro as the preferred form for marking pointer arguments as non-NULL. Add a check suggesting the macro over the raw __attribute__((nonnull)) spelling, consistent with the existing attribute conversion suggestions.
Examples:
WARNING: Prefer __nonnull_args(1, 2) over __attribute__((nonnull(1, 2))) #11: FILE: drivers/soc/aspeed/aspeed-lpc-snoop.c:230:
+__attribute__((nonnull(1, 2)))
WARNING: Prefer __nonnull_args() over __attribute__((nonnull)) #11: FILE: drivers/soc/aspeed/aspeed-lpc-snoop.c:283:
+__attribute__((nonnull))
--- scripts/checkpatch.pl | 3 +++ 1 file changed, 3 insertions(+)
scripts/checkpatch.pl +3 -0
@@ -6856,6 +6856,7 @@ sub process { "no_caller_saved_registers" => "__no_caller_saved_registers", "noclone" => "__noclone", "noinline" => "noinline", + "nonnull" => "__nonnull_args", "nonstring" => "__nonstring", "noreturn" => "__noreturn", "packed" => "__packed",
@@ -6876,6 +6877,8 @@ sub process { if ($curr_attr eq "format" && $params) { $params =~ /^\s*\(\s*(\w+)\s*,\s*(.*)/; $new = "__$1\($2"; + } elsif ($curr_attr eq "nonnull" && $params eq "") { + $new = "$new()"; } else { $new = "$new$params"; }
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewRe: [PATCH 10/10] checkpatch: suggest nonnull attribute conversion
Sashiko has reviewed this patch and found no issues.
Quoted 11 lines
The kernel provides the
__nonnull_args()macro as the preferred form for marking pointer arguments as non-NULL. Add a check suggesting the macro over the raw __attribute__((nonnull)) spelling, consistent with the existing attribute conversion suggestions.Examples:
WARNING: Prefer
__nonnull_args(1, 2)over__attribute__((nonnull(1, 2)))#11: FILE:drivers/soc/aspeed/aspeed-lpc-snoop.c:230:
+__attribute__((nonnull(1, 2)))
Quoted 5 lines
WARNING: Prefer
__nonnull_args()over __attribute__((nonnull)) #11: FILE:drivers/soc/aspeed/aspeed-lpc-snoop.c:283:
+__attribute__((nonnull))Signed-off-by Dmitry Ilvokhin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Joe Perches
maintainerRe: [PATCH 10/10] checkpatch: suggest nonnull attribute conversion
In reply to Dmitry IlvokhinQuoted 11 lines · Dmitry Ilvokhin
The kernel provides the
__nonnull_args()macro as the preferred form for marking pointer arguments as non-NULL. Add a check suggesting the macro over the raw __attribute__((nonnull)) spelling, consistent with the existing attribute conversion suggestions.Examples:
WARNING: Prefer
__nonnull_args(1, 2)over__attribute__((nonnull(1, 2)))#11: FILE:drivers/soc/aspeed/aspeed-lpc-snoop.c:230:
+__attribute__((nonnull(1, 2)))
Quoted 5 lines
WARNING: Prefer
__nonnull_args()over __attribute__((nonnull)) #11: FILE:drivers/soc/aspeed/aspeed-lpc-snoop.c:283:
+__attribute__((nonnull))
Seems sensible, thanks.
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
Quoted 18 lines
scripts/checkpatch.pl +3
-0@@ -6856,6 +6856,7 @@ sub process { "no_caller_saved_registers" => "__no_caller_saved_registers", "noclone" => "__noclone", "noinline" => "noinline", + "nonnull" => "__nonnull_args", "nonstring" => "__nonstring", "noreturn" => "__noreturn", "packed" => "__packed",@@ -6876,6 +6877,8 @@ sub process { if ($curr_attr eq "format" && $params) { $params =~ /^\s*\(\s*(\w+)\s*,\s*(.*)/; $new = "__$1\($2"; + } elsif ($curr_attr eq "nonnull" && $params eq "") { + $new = "$new()"; } else { $new = "$new$params"; }
Patchwork
CI✗ LGCI.VerificationFailed: failure for treewide: switch to __nonnull_args() macro
In reply to Dmitry Ilvokhin== Series Details ==
== Series Details ==
Series: treewide: switch to __nonnull_args() macro
URL : https://patchwork.freedesktop.org/series/177031/
State : failure
== Summary ==
Series author address '[email protected]' is not on the allowlist, which prevents CI from being automatically triggered. If you want CI to run for this series, ask Patchwork project owners to click 'retest' on the series in Patchwork. Exception occurred during validation, bailing out!
Build URL: http://gfx-ci.igk.intel.com:8080/job/CI_PW_kernel/191587/ (on built-in)
Randy Dunlap
reviewerQuoted 20 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the__nonnull_args()macro to wrap the raw compiler attribute, keeping the attribute's quirks in one place rather than open-coded at every call site.This series replaces the remaining open-coded __attribute__((nonnull)) users with
__nonnull_args()to standardize nonnull attribute usage across the tree.Each patch can be applied separately by the respective maintainers. The only dependency is kernel-doc: the string and
lib/list_sortpatches need patch 1 ("docs:xforms_lists: support__nonnull_args()") in the same release, otherwisestrends()andlist_sort()drop out of the generated documentation.Latest Sparse release could not properly parse
__nonnull_args()without arguments. Fix was proposed [1] and merged, but until updated version of Sparse will reach wide masses it might trip on__nonnull_args()without arguments.
Quoted 5 lines
There are few more instances of __attribute__((nonnull)) usages left in the tools subdirectory, they are perf related copied files and can (should?) be updated separately after this patchset lands.
Build-tested allmodconfig with GCC 11.5.0 and clang 22.1.8.
What ARCH(es)?
Did you mean to use such an "old" version of GCC?
thanks.
Quoted 32 lines
[1]: https://lore.kernel.org/all/[email protected]/
Dmitry Ilvokhin (10):
docs:xforms_lists: support__nonnull_args()
string: Switch to__nonnull_args()macrolib/list_sort: Switch to__nonnull_args()macro
xarray: switch to__nonnull_args()macro drm/i915: switch to__nonnull_args()macro drm/amdgpu: switch to__nonnull_args()macro drm/gem: Switch to__nonnull_args()macro
leds: pwm: Switch to__nonnull_args()macro
soc: aspeed: lpc-snoop: Switch to__nonnull_args()macro
checkpatch: suggest nonnull attribute conversiondrivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_object.h | 4 ++-- drivers/gpu/drm/i915/i915_request.h | 4 ++-- drivers/leds/leds-pwm.c | 2 +- drivers/soc/aspeed/aspeed-lpc-snoop.c | 4 ++-- include/drm/drm_gem.h | 2 +- include/linux/list_sort.h | 4 ++-- include/linux/string.h | 2 +- include/linux/xarray.h | 4 ++-- lib/list_sort.c | 6 +++--- scripts/checkpatch.pl | 3 +++ tools/include/linux/compiler.h | 4 ++++ tools/lib/python/kdoc/xforms_lists.py | 1 + 13 files changed, 25 insertions(+), 17 deletions(-)base-commit:
6b4b543fa18757297ac756a6fe6e64f506b7844a
Signature · 1 line
~Randy
Quoted 23 lines · Randy Dunlap
Quoted 20 lines · Dmitry Ilvokhin
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the__nonnull_args()macro to wrap the raw compiler attribute, keeping the attribute's quirks in one place rather than open-coded at every call site.This series replaces the remaining open-coded __attribute__((nonnull)) users with
__nonnull_args()to standardize nonnull attribute usage across the tree.Each patch can be applied separately by the respective maintainers. The only dependency is kernel-doc: the string and
lib/list_sortpatches need patch 1 ("docs:xforms_lists: support__nonnull_args()") in the same release, otherwisestrends()andlist_sort()drop out of the generated documentation.Latest Sparse release could not properly parse
__nonnull_args()without arguments. Fix was proposed [1] and merged, but until updated version of Sparse will reach wide masses it might trip on__nonnull_args()without arguments.
Quoted 7 lines
Quoted 5 lines
There are few more instances of __attribute__((nonnull)) usages left in the tools subdirectory, they are perf related copied files and can (should?) be updated separately after this patchset lands.
Build-tested allmodconfig with GCC 11.5.0 and clang 22.1.8.
What ARCH(es)?
Fair point, I should have mentioned that I run this on x86_64 and aarch64.
Quoted 2 lines
Did you mean to use such an "old" version of GCC?
There is no grand plan behind that to be honest, I used it, because this is a version of GCC that comes with CentOS Stream 9 on the box I tested the change.
To be on the safe side, I checked patchset still builds on GCC 16.2.1 on allmodconfig x86_64.
Andrew Morton
maintainerQuoted 10 lines · On Wed, 28 Oct 2026 08:19:39 +0000 Dmitry Ilvokhin <[email protected]> wrote:
Commit
22302af28d3f("cleanup: Annotate guard constructors with nonnull") added the__nonnull_args()macro to wrap the raw compiler attribute, keeping the attribute's quirks in one place rather than open-coded at every call site.This series replaces the remaining open-coded __attribute__((nonnull)) users with
__nonnull_args()to standardize nonnull attribute usage across the tree.Each patch can be applied separately by the respective maintainers.
Thanks.
Standard routine: I'll grab everything. If maintainers send along an ack then I'll add it (thinks). If some of these patches later pop up in linux-next then Mark will inform us and I'll drop the mm.git copy.