Skip to contentSkip to conversation

Replace numeric parameter like 0444 with macro

PATCH New Baole Ni 1 participant 1 message Aug 2, 2016

Subsystems (2)
lore
Share & tools
lore

Baole Ni

author
#0 lore raw

PATCH 83/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/block/drbd/drbd_main.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/block/drbd/drbd_main.c +8 -8
index 2ba1494..467e9da 100644
@@ -80,10 +80,10 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(DRBD_MAJOR);
 MODULE_PARM_DESC(allow_oos, "DONT USE!");
 /* thanks to these macros, if compiled into the kernel (not-module),
  * this becomes the boot parameter drbd.minor_count */
-module_param(minor_count, uint, 0444);
-module_param(disable_sendpage, bool, 0644);
+module_param(minor_count, uint, S_IRUSR | S_IRGRP | S_IROTH);
+module_param(disable_sendpage, bool, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 module_param(allow_oos, bool, 0);
-module_param(proc_details, int, 0644);
+module_param(proc_details, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
 #ifdef CONFIG_DRBD_FAULT_INJECTION
 int enable_faults;
@@ -91,13 +91,13 @@ int fault_rate;
 static int fault_count;
 int fault_devs;
 /* bitmap of enabled faults */
-module_param(enable_faults, int, 0664);
+module_param(enable_faults, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
 /* fault rate % value - applies to all enabled faults */
-module_param(fault_rate, int, 0664);
+module_param(fault_rate, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
 /* count of faults inserted */
-module_param(fault_count, int, 0664);
+module_param(fault_count, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
 /* bitmap of devices to insert faults on */
-module_param(fault_devs, int, 0644);
+module_param(fault_devs, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 #endif
 
 /* module parameter, defined */
@@ -110,7 +110,7 @@ int proc_details;       /* Detail level in proc drbd*/
  * to run. Default is /sbin/drbdadm */
 char usermode_helper[80] = "/sbin/drbdadm";
 
-module_param_string(usermode_helper, usermode_helper, sizeof(usermode_helper), 0644);
+module_param_string(usermode_helper, usermode_helper, sizeof(usermode_helper), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
 /* in 2.6.x, our device mapping and config info contains our virtual gendisks
  * as member "struct gendisk *vdisk;"
Signature · 1 line
2.9.2