Skip to contentSkip to conversation

Replace numeric parameter like 0444 with macro

PATCH NAK Baole Ni 4 participants 4 messages Aug 2, 2016

Subsystems (2)
lore
Share & tools
lore

Baole Ni

author
#0 lore raw

PATCH 290/1285 Replace numeric parameter like 0444 with macro

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission. As we know, these numeric value for access permission have had the corresponding macro, and that using macro can improve the robustness and readability of the code, thus, I suggest replacing the numeric parameter with the macro.

---
 drivers/input/touchscreen/ads7846.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/ads7846.c +1 -1
index a61b215..0f882cb 100644
@@ -591,7 +591,7 @@ static ssize_t ads7846_disable_store(struct device *dev,
 	return count;
 }
 
-static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store);
+static DEVICE_ATTR(disable, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, ads7846_disable_show, ads7846_disable_store);
 
 static struct attribute *ads784x_attributes[] = {
 	&dev_attr_pen_down.attr,
Signature · 1 line
2.9.2
#1 lore raw
Quoted 5 lines · Baole Ni

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission. As we know, these numeric value for access permission have had the corresponding macro, and that using macro can improve the robustness and readability of the code, thus, I suggest replacing the numeric parameter with the macro.

Please split these up and send them independently to the relevant maintainers with sensible subject lines - a single 1000+ patch series is far too large and you're CCing random people so it's hard to tell which patches are relevant (for example the batch I'm replying to here are for the input subsystem which I don't maintain so I'm not 100% sure why I'm being copied here).

With this sort of thing it's often best to send one series per directory or something similar.

#2 lore raw
Quoted 14 lines · Mark Brown
Quoted 5 lines · Baole Ni

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission. As we know, these numeric value for access permission have had the corresponding macro, and that using macro can improve the robustness and readability of the code, thus, I suggest replacing the numeric parameter with the macro.

Please split these up and send them independently to the relevant maintainers with sensible subject lines - a single 1000+ patch series is far too large and you're CCing random people so it's hard to tell which patches are relevant (for example the batch I'm replying to here are for the input subsystem which I don't maintain so I'm not 100% sure why I'm being copied here).

Quoted 3 lines

With this sort of thing it's often best to send one series per directory or something similar.

I would recommend just adding whatever script you used to find all of these to patchcheck or coccinelle, then let people familiar with each subsystem make and submit the fix-ups for each subsystem. You won't get 1000+ patches to your name, but the work still gets done and you avoid bothering a lot of people.

(I got about several of these for files I've never touched :/)

Thanks,
Andrew

maintainer
#3 lore raw
In reply to Baole Ni
Quoted 17 lines · Baole Ni

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission. As we know, these numeric value for access permission have had the corresponding macro, and that using macro can improve the robustness and readability of the code, thus, I suggest replacing the numeric parameter with the macro.

---
 drivers/input/touchscreen/ads7846.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/ads7846.c +0 -0
index a61b215..0f882cb 100644

drivers/input/touchscreen/ads7846.c static ssize_t ads7846_disable_store(struct device *dev, · line 594

Quoted 5 lines
drivers/input/touchscreen/ads7846.c +1 -1
@@ -591,7 +591,7 @@ static ssize_t ads7846_disable_store(struct device *dev,
 	return count;
 }
 
-static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store);
+static DEVICE_ATTR(disable, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, ads7846_disable_show, ads7846_disable_store);

No, this does not improve neither robustness nor readability.

Thanks.

Signature · 1 line
Dmitry