All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1086/1285] Replace numeric parameter like 0444 with macro
@ 2016-08-02 12:15 ` Baole Ni
  0 siblings, 0 replies; 6+ messages in thread
From: Baole Ni @ 2016-08-02 12:15 UTC (permalink / raw)
  To: mareklindner, sw, a, davem, jiangshanlai, m.chehab, gregkh,
	m.szyprowski, kyungmin.park, k.kozlowski
  Cc: b.a.t.m.a.n, netdev, linux-kernel, chuansheng.liu, baolex.ni,
	gang.chen.5i5j, mhocko, koct9i, aarcange, aryabinin

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 <chuansheng.liu@intel.com>
Signed-off-by: Baole Ni <baolex.ni@intel.com>
---
 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1086/1285] Replace numeric parameter like 0444 with macro
@ 2016-08-02 12:15 ` Baole Ni
  0 siblings, 0 replies; 6+ messages in thread
From: Baole Ni @ 2016-08-02 12:15 UTC (permalink / raw)
  To: mareklindner-rVWd3aGhH2z5bpWLKbzFeg,
	sw-2YrNx6rUIHYiY0qSoAWiAoQuADTiUCJX, a,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	jiangshanlai-Re5JQEeQqe8AvxtiuMwx3w,
	m.chehab-Sze3O3UU22JBDgjK7y7TUQ,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ,
	kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ,
	k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ
  Cc: aarcange-H+wXaHxf7aLQT0dZR+AlfA, mhocko-IBi9RG/b67k,
	gang.chen.5i5j-Re5JQEeQqe8AvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	baolex.ni-ral2JQCrhuEAvxtiuMwx3w,
	aryabinin-5HdwGun5lf+gSpxsJD1C4w,
	chuansheng.liu-ral2JQCrhuEAvxtiuMwx3w,
	koct9i-Re5JQEeQqe8AvxtiuMwx3w

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 <chuansheng.liu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Baole Ni <baolex.ni-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [B.A.T.M.A.N.] [PATCH 1086/1285] Replace numeric parameter like 0444 with macro
@ 2016-08-02 12:15 ` Baole Ni
  0 siblings, 0 replies; 6+ messages in thread
From: Baole Ni @ 2016-08-02 12:15 UTC (permalink / raw)
  To: mareklindner, sw, a, davem, jiangshanlai, m.chehab, gregkh,
	m.szyprowski, kyungmin.park, k.kozlowski
  Cc: aarcange, mhocko, gang.chen.5i5j, netdev, b.a.t.m.a.n,
	linux-kernel, baolex.ni, aryabinin, chuansheng.liu, koct9i

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 <chuansheng.liu@intel.com>
Signed-off-by: Baole Ni <baolex.ni@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 1086/1285] Replace numeric parameter like 0444 with macro
@ 2016-08-02 13:38   ` Sven Eckelmann
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2016-08-02 13:38 UTC (permalink / raw)
  To: b.a.t.m.a.n
  Cc: Baole Ni, mareklindner, sw, a, davem, jiangshanlai, m.chehab,
	gregkh, m.szyprowski, kyungmin.park, k.kozlowski, aarcange,
	mhocko, gang.chen.5i5j, netdev, linux-kernel, aryabinin,
	chuansheng.liu, koct9i

[-- Attachment #1: Type: text/plain, Size: 2067 bytes --]

On Dienstag, 2. August 2016 20:15:13 CEST Baole Ni wrote:
[...]
> 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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1086/1285] Replace numeric parameter like 0444 with macro
@ 2016-08-02 13:38   ` Sven Eckelmann
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2016-08-02 13:38 UTC (permalink / raw)
  To: b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r
  Cc: aarcange-H+wXaHxf7aLQT0dZR+AlfA,
	k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ, mhocko-IBi9RG/b67k,
	mareklindner-rVWd3aGhH2z5bpWLKbzFeg, a,
	jiangshanlai-Re5JQEeQqe8AvxtiuMwx3w,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	chuansheng.liu-ral2JQCrhuEAvxtiuMwx3w, Baole Ni,
	kyungmin.park-Sze3O3UU22JBDgjK7y7TUQ,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
	aryabinin-5HdwGun5lf+gSpxsJD1C4w,
	gang.chen.5i5j-Re5JQEeQqe8AvxtiuMwx3w,
	m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ,
	davem-fT/PcQaiUtIeIZ0/mPfg9Q, koct9i-Re5JQEeQqe8AvxtiuMwx3w,
	m.chehab-Sze3O3UU22JBDgjK7y7TUQ

[-- Attachment #1: Type: text/plain, Size: 2067 bytes --]

On Dienstag, 2. August 2016 20:15:13 CEST Baole Ni wrote:
[...]
> 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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 1086/1285] Replace numeric parameter like 0444 with macro
@ 2016-08-02 13:38   ` Sven Eckelmann
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2016-08-02 13:38 UTC (permalink / raw)
  To: b.a.t.m.a.n
  Cc: aarcange, k.kozlowski, mhocko, mareklindner, a, jiangshanlai,
	linux-kernel, chuansheng.liu, Baole Ni, kyungmin.park, netdev,
	gregkh, aryabinin, gang.chen.5i5j, m.szyprowski, davem, koct9i,
	m.chehab

[-- Attachment #1: Type: text/plain, Size: 2067 bytes --]

On Dienstag, 2. August 2016 20:15:13 CEST Baole Ni wrote:
[...]
> 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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-02 14:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-02 12:15 [PATCH 1086/1285] Replace numeric parameter like 0444 with macro Baole Ni
2016-08-02 12:15 ` [B.A.T.M.A.N.] " Baole Ni
2016-08-02 12:15 ` Baole Ni
2016-08-02 13:38 ` [B.A.T.M.A.N.] " Sven Eckelmann
2016-08-02 13:38   ` Sven Eckelmann
2016-08-02 13:38   ` Sven Eckelmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.