* [PATCH] checkpatch: don't require octal permissions for "0"
@ 2017-12-10 14:04 Bartosz Golaszewski
2017-12-10 22:56 ` Joe Perches
2017-12-11 2:19 ` Joe Perches
0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2017-12-10 14:04 UTC (permalink / raw)
To: Andy Whitcroft, Joe Perches, Andy Shevchenko
Cc: linux-kernel, Bartosz Golaszewski
If the permission value is 0, don't raise the NON_OCTAL_PERMISSIONS
error. There's no possibility of an error if there are no permissions.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6b130a4116fa..ea98e298d3ac 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6321,7 +6321,7 @@ sub process {
if ($stat =~ /$test/) {
my $val = $1;
$val = $6 if ($skip_args ne "");
- if (($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
+ if (($val ne "0" && $val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
($val =~ /^$Octal$/ && length($val) ne 4)) {
ERROR("NON_OCTAL_PERMISSIONS",
"Use 4 digit octal (0777) not decimal permissions\n" . "$here\n" . $stat_real);
--
2.15.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpatch: don't require octal permissions for "0"
2017-12-10 14:04 [PATCH] checkpatch: don't require octal permissions for "0" Bartosz Golaszewski
@ 2017-12-10 22:56 ` Joe Perches
2017-12-11 2:19 ` Joe Perches
1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2017-12-10 22:56 UTC (permalink / raw)
To: Bartosz Golaszewski, Andy Whitcroft, Andy Shevchenko; +Cc: linux-kernel
On Sun, 2017-12-10 at 15:04 +0100, Bartosz Golaszewski wrote:
> If the permission value is 0, don't raise the NON_OCTAL_PERMISSIONS
> error. There's no possibility of an error if there are no permissions.
Hi Bartosz
This response below is the same as another email thread
-------------
Personally, I prefer 4 digit octal in most cases as it
shows the coder knows that the argument is a permissions
use and not just some generic 0.
There are not many uses of 0 for permissions outside of
module_param*.
I suppose all the variants of module_param calls, as a
0 there is specifically a "not to appear in sysfs" flag,
could or should be excluded from that octal test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpatch: don't require octal permissions for "0"
2017-12-10 14:04 [PATCH] checkpatch: don't require octal permissions for "0" Bartosz Golaszewski
2017-12-10 22:56 ` Joe Perches
@ 2017-12-11 2:19 ` Joe Perches
2017-12-11 9:39 ` Bartosz Golaszewski
1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2017-12-11 2:19 UTC (permalink / raw)
To: Bartosz Golaszewski, Andy Whitcroft, Andy Shevchenko; +Cc: linux-kernel
On Sun, 2017-12-10 at 15:04 +0100, Bartosz Golaszewski wrote:
> If the permission value is 0, don't raise the NON_OCTAL_PERMISSIONS
> error. There's no possibility of an error if there are no permissions.
>
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
> ---
> scripts/checkpatch.pl | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 6b130a4116fa..ea98e298d3ac 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -6321,7 +6321,7 @@ sub process {
> if ($stat =~ /$test/) {
> my $val = $1;
> $val = $6 if ($skip_args ne "");
> - if (($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
> + if (($val ne "0" && $val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
> ($val =~ /^$Octal$/ && length($val) ne 4)) {
> ERROR("NON_OCTAL_PERMISSIONS",
> "Use 4 digit octal (0777) not decimal permissions\n" . "$here\n" . $stat_real);
perhaps
---
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6b130a4116fa..950bbc0e6e3f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6321,7 +6321,8 @@ sub process {
if ($stat =~ /$test/) {
my $val = $1;
$val = $6 if ($skip_args ne "");
- if (($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
+ if ($func !~ /^module_param/ &&
+ ($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
($val =~ /^$Octal$/ && length($val) ne 4)) {
ERROR("NON_OCTAL_PERMISSIONS",
"Use 4 digit octal (0777) not decimal permissions\n" . "$here\n" . $stat_real);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] checkpatch: don't require octal permissions for "0"
2017-12-11 2:19 ` Joe Perches
@ 2017-12-11 9:39 ` Bartosz Golaszewski
0 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2017-12-11 9:39 UTC (permalink / raw)
To: Joe Perches; +Cc: Andy Whitcroft, Andy Shevchenko, Linux Kernel Mailing List
2017-12-11 3:19 GMT+01:00 Joe Perches <joe@perches.com>:
> On Sun, 2017-12-10 at 15:04 +0100, Bartosz Golaszewski wrote:
>> If the permission value is 0, don't raise the NON_OCTAL_PERMISSIONS
>> error. There's no possibility of an error if there are no permissions.
>>
>> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
>> ---
>> scripts/checkpatch.pl | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index 6b130a4116fa..ea98e298d3ac 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -6321,7 +6321,7 @@ sub process {
>> if ($stat =~ /$test/) {
>> my $val = $1;
>> $val = $6 if ($skip_args ne "");
>> - if (($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
>> + if (($val ne "0" && $val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
>> ($val =~ /^$Octal$/ && length($val) ne 4)) {
>> ERROR("NON_OCTAL_PERMISSIONS",
>> "Use 4 digit octal (0777) not decimal permissions\n" . "$here\n" . $stat_real);
>
> perhaps
> ---
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 6b130a4116fa..950bbc0e6e3f 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -6321,7 +6321,8 @@ sub process {
> if ($stat =~ /$test/) {
> my $val = $1;
> $val = $6 if ($skip_args ne "");
> - if (($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
> + if ($func !~ /^module_param/ &&
> + ($val =~ /^$Int$/ && $val !~ /^$Octal$/) ||
> ($val =~ /^$Octal$/ && length($val) ne 4)) {
> ERROR("NON_OCTAL_PERMISSIONS",
> "Use 4 digit octal (0777) not decimal permissions\n" . "$here\n" . $stat_real);
I would still check for octal permissions for anything else but "0"
here. I'll send a patch shortly.
Thanks,
Bartosz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-11 9:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-10 14:04 [PATCH] checkpatch: don't require octal permissions for "0" Bartosz Golaszewski
2017-12-10 22:56 ` Joe Perches
2017-12-11 2:19 ` Joe Perches
2017-12-11 9:39 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).