[PATCH 1086/1285] Replace numeric parameter like 0444 with macro

Subsystems: batman advanced, the rest

DORMANTno replies

2 messages, 2 authors, 2016-08-02 · open the first message on its own page

[PATCH 1086/1285] Replace numeric parameter like 0444 with macro

From: Baole Ni <hidden>
Date: 2016-08-02 14:20:21

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.

Signed-off-by: Chuansheng Liu <redacted>
Signed-off-by: Baole Ni <redacted>
---
 net/batman-adv/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 5f2974b..25759b9 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -1313,7 +1313,7 @@ static struct kparam_string batadv_param_string_ra = {
 };
 
 module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,
-		0644);
+		S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 module_init(batadv_init);
 module_exit(batadv_exit);
 
-- 
2.9.2

Re: [B.A.T.M.A.N.] [PATCH 1086/1285] Replace numeric parameter like 0444 with macro

From: Sven Eckelmann <sven@narfation.org>
Date: 2016-08-02 13:48:24

On Dienstag, 2. August 2016 20:15:13 CEST Baole Ni wrote:
[...]
quoted hunk
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 5f2974b..25759b9 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -1313,7 +1313,7 @@ static struct kparam_string batadv_param_string_ra = {
 };
 
 module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,
-		0644);
+		S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 module_init(batadv_init);
 module_exit(batadv_exit);
Doesn't seem to apply on current net-next:

    $ git am -3 16577.patch
    Applying: Replace numeric parameter like 0444 with macro
    Using index info to reconstruct a base tree...
    M       net/batman-adv/main.c
    Falling back to patching base and 3-way merge...
    Auto-merging net/batman-adv/main.c
    CONFLICT (content): Merge conflict in net/batman-adv/main.c
    error: Failed to merge in the changes.
    Patch failed at 0001 Replace numeric parameter like 0444 with macro
    The copy of the patch that failed is found in: .git/rebase-apply/patch
    When you have resolved this problem, run "git am --continue".
    If you prefer to skip this patch, run "git am --skip" instead.
    To restore the original branch and stop patching, run "git am --abort".

The code for it can now be found at net/batman-adv/bat_algo.c

Also the prefix "batman-adv: " is missing in the subject and you should
include <linux/stat.h> in net/batman-adv/bat_algo.c to make sure that these
macros are actually defined before you use them.

So you would end up with something more like:
--- a/net/batman-adv/bat_algo.c
+++ b/net/batman-adv/bat_algo.c
@@ -22,6 +22,7 @@
 #include <linux/moduleparam.h>
 #include <linux/printk.h>
 #include <linux/seq_file.h>
+#include <linux/stat.h>
 #include <linux/stddef.h>
 #include <linux/string.h>
 
@@ -137,4 +138,4 @@ static struct kparam_string batadv_param_string_ra = {
 };
 
 module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,
-		0644);
+		S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
Kind regards,
	Sven
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help