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] [thread-next>] [day] [month] [year] [list]
Message-ID: <202d1efe-fcd4-1155-ad80-f44a2345dc97@mev.co.uk>
Date:   Wed, 13 Jun 2018 13:01:35 +0100
From:   Ian Abbott <abbotti@....co.uk>
To:     Chris Opperman <eklikeroomys@...il.com>
Cc:     H Hartley Sweeten <hsweeten@...ionengravers.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Simo Koskinen <koskisoft@...il.com>,
        Frank Mori Hess <fmh6jj@...il.com>,
        devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] staging: comedi: Improved readability of function
 comedi_nsamples_left.

On 12/06/18 22:09, Chris Opperman wrote:
> Changes since v3:
> a) Reverted u64 to unsigned long long and u32 to unsigned int.
> b) Added patch versioning.
> c) Changed type of scans_left to unsigned long long to avoid cast.
> d) Clarified and updated changelog.
> 
>> 8-----------------------------------------------------------------------8<
> 
> Improve readability of comedi_nsamples_left:
> a) Reduce nesting by using more return statements.
> b) Declare variables scans_left and samples_left at start of function.
> c) Change type of scans_Left to unsigned long long to avoid cast.
> 
> Signed-off-by: Chris Opperman <eklikeroomys@...il.com>
> ---
>   drivers/staging/comedi/drivers.c | 26 +++++++++++++-------------
>   1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
> index 9d73347..57dd63d 100644
> --- a/drivers/staging/comedi/drivers.c
> +++ b/drivers/staging/comedi/drivers.c
> @@ -473,21 +473,21 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
>   {
>   	struct comedi_async *async = s->async;
>   	struct comedi_cmd *cmd = &async->cmd;
> +	unsigned long long scans_left;
> +	unsigned long long samples_left;
> 
> -	if (cmd->stop_src == TRIG_COUNT) {
> -		unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg);
> -		unsigned int scan_pos =
> -		    comedi_bytes_to_samples(s, async->scan_progress);
> -		unsigned long long samples_left = 0;
> -
> -		if (scans_left) {
> -			samples_left = ((unsigned long long)scans_left *
> -					cmd->scan_end_arg) - scan_pos;
> -		}
> +	if (cmd->stop_src != TRIG_COUNT)
> +		return nsamples;
> 
> -		if (samples_left < nsamples)
> -			nsamples = samples_left;
> -	}
> +	scans_left = __comedi_nscans_left(s, cmd->stop_arg);
> +	if (!scans_left)
> +		return 0;
> +
> +	samples_left = scans_left * cmd->scan_end_arg -
> +		comedi_bytes_to_samples(s, async->scan_progress);
> +
> +	if (samples_left < nsamples)
> +		return samples_left;
>   	return nsamples;
>   }
>   EXPORT_SYMBOL_GPL(comedi_nsamples_left);
> --
> 2.1.4
> 

The code changes look fine.  You just need to correct the commit 
message, as pointed out by Dan Carpenter.

For reference, everything below the "---" cut-off line gets stripped out 
of the commit message in the git repository, so that is a good place to 
add comments about the patch itself (such as change logs) that do not 
belong in the commit message.

-- 
-=( Ian Abbott <abbotti@....co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ