Skip to contentSkip to conversation

checkpatch: fix IIO_DEV_ATTR false positives

PATCH New Tudor Gheorghiu 1 participant 1 message Oct 2, 2024 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: fix IIO_DEV_ATTR false positives

The NON_OCTAL_PERMISSIONS checkpatch error can trigger false positives when searching for the "IIO_DEV_ATTR_[A-Z_]+" pattern. The script checks for any matching macros and reports an error if the first argument is a literal and is not in octal notation.

There are a few other macros that match this pattern, in which the first argument is not a file permission, therefore they don't necessarily need to be matched by this condition.

The macros are all defined in include/linux/iio/sysfs.h:

Quoted 4 lines

#define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store) #define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) #define IIO_DEV_ATTR_INT_TIME_AVAIL(_show) #define IIO_DEV_ATTR_TEMP_RAW(_show)

The script is fixed by matching IIO_DEV_ATTR_SAMP_FREQ exclusively.

Discovered by running checkpatch on some staging iio drivers:
https://lore.kernel.org/linux-iio/[email protected]/

Potential checkpatch issue identified and patch suggested:
https://lore.kernel.org/linux-iio/[email protected]/

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index 4427572b2477..2fb4549fede2 100755
@@ -817,7 +817,7 @@ our @mode_permission_funcs = (
 	["debugfs_create_(?:file|u8|u16|u32|u64|x8|x16|x32|x64|size_t|atomic_t|bool|blob|regset32|u32_array)", 2],
 	["proc_create(?:_data|)", 2],
 	["(?:CLASS|DEVICE|SENSOR|SENSOR_DEVICE|IIO_DEVICE)_ATTR", 2],
-	["IIO_DEV_ATTR_[A-Z_]+", 1],
+	["IIO_DEV_ATTR_SAMP_FREQ", 1],
 	["SENSOR_(?:DEVICE_|)ATTR_2", 2],
 	["SENSOR_TEMPLATE(?:_2|)", 3],
 	["__ATTR", 2],
Signature · 1 line
2.43.0