lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 03 Jul 2018 18:40:54 -0700
From:   Joe Perches <joe@...ches.com>
To:     Prakruthi Deepak Heragu <pheragu@...eaurora.org>, apw@...onical.com
Cc:     linux-kernel@...r.kernel.org, ckadabi@...eaurora.org,
        bryanh@...eaurora.org, tsoni@...eaurora.org,
        Patrick Pannuto <ppannuto@...eaurora.org>,
        Stepan Moskovchenko <stepanm@...eaurora.org>
Subject: Re: [PATCH v1] checkpatch: Check for invalid return codes

On Tue, 2018-07-03 at 16:41 -0700, Prakruthi Deepak Heragu wrote:
> The only valid integer return is 0, anything else
> following "return" should be -ERRCODE or a function.

Integer return values can be positive constant and correct.

So perhaps better:

Negative integer return codes should prefer to use #define -<ERRNO>
values instead of negative numbers.

> Also, display context
> so that the user knows where the return value is incorrect.
> 
> http://lkml.org/lkml/2010/7/23/318
>   There's lots of "return -1;" statements in this patch - it's obscene
>   that this is used to indicate "some error occurred" in kernel space
>   rather than a real errno value - even when an existing function
>   (eg, request_irq) gave you an error code already.

This bit is superfluous and if you are going to quote
someone in a patch commit, it's nice to cc: them.

> Signed-off-by: Patrick Pannuto <ppannuto@...eaurora.org>
> Signed-off-by: Stepan Moskovchenko <stepanm@...eaurora.org>
> Signed-off-by: Prakruthi Deepak Heragu <pheragu@...eaurora.org>

Does it really take 3 people to sign-off on this patch?

> ---
> Changes in v1:
> - Use CHK instead of ERROR
> - Rephrase the warning message
> - Provide the file name and line number where return value is incorrect
> 
>  scripts/checkpatch.pl | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index a9c0550..2808c27 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -6197,6 +6197,12 @@ sub process {
>  			     "switch default: should use break\n" . $herectx);
>  		}
>  
> +# check for return codes on error paths



> +		if ($line =~ /\breturn\s+-\d+/) {
> +			CHK("NO_ERROR_CODE",

NO_ERROR_CODE isn't very obvious to me.
How about NEGATIVE_ERRNO or APPROPRIATE_ERRNO

> +			      "invalid return value, please return -<APPROPRIATE_ERRNO>\n" . $herecurr);
> +		}
> +
>  # check for gcc specific __FUNCTION__
>  		if ($line =~ /\b__FUNCTION__\b/) {
>  			if (WARN("USE_FUNC",

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ