Skip to contentSkip to conversation

Replace numeric parameter like 0444 with macro

PATCH NAK Baole Ni 2 participants 2 messages Aug 2, 2016 – Aug 3, 2016

lore
Share & tools
lore

Baole Ni

author
#0 lore raw

PATCH 309/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/lguest/interrupts_and_traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/lguest/interrupts_and_traps.c +1 -1
index 67392b6..ebd3723 100644
@@ -21,7 +21,7 @@
 
 /* Allow Guests to use a non-128 (ie. non-Linux) syscall trap. */
 static unsigned int syscall_vector = IA32_SYSCALL_VECTOR;
-module_param(syscall_vector, uint, 0444);
+module_param(syscall_vector, uint, S_IRUSR | S_IRGRP | S_IROTH);
 
 /* The address of the interrupt handler is split into two bits: */
 static unsigned long idt_address(u32 lo, u32 hi)
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.

I find the numbers far, far more readable.

Cheers,
Rusty.

Quoted 9 lines

/* Allow Guests to use a non-128 (ie. non-Linux) syscall trap. */ static unsigned int syscall_vector = IA32_SYSCALL_VECTOR;

drivers/lguest/interrupts_and_traps.c +1 -1
-module_param(syscall_vector, uint, 0444);
+module_param(syscall_vector, uint, S_IRUSR | S_IRGRP | S_IROTH);
 
 /* The address of the interrupt handler is split into two bits: */
 static unsigned long idt_address(u32 lo, u32 hi)
Signature · 1 line
2.9.2