linux-6.17/kernel/module/sysfs.c:275: Always true test in for loop ?

From: David Binderman

Date: Tue Sep 30 2025 - 06:25:40 EST


Hello there,

Static analyser cppcheck says:

linux-6.17/kernel/module/sysfs.c:275:20: style: Pointer expression 'attr=&mod->modinfo_attrs[i]' converted to bool is always true. [knownPointerToBool]

Source code is

for (i = 0; (attr = &mod->modinfo_attrs[i]); i++) {

Suggest code rework.

Regards

David Binderman