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]
Message-ID: <f49d7b55-a857-763c-4143-c6c5a43fc836@mev.co.uk>
Date:   Wed, 8 Mar 2017 12:57:48 +0000
From:   Ian Abbott <abbotti@....co.uk>
To:     simran singhal <singhalsimran0@...il.com>
Cc:     hsweeten@...ionengravers.com, gregkh@...uxfoundation.org,
        devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
        outreachy-kernel@...glegroups.com
Subject: Re: [PATCH 6/6] staging: comedi: Using macro DIV_ROUND_UP

On 21/02/17 18:28, simran singhal wrote:
> The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)).
> It clarifies the divisor calculations. This occurence was detected using
> the coccinelle script:
>
> @@
> expression e1;
> expression e2;
> @@
> (
> - ((e1) + e2 - 1) / (e2)
> + DIV_ROUND_UP(e1,e2)
> |
> - ((e1) + (e2 - 1)) / (e2)
> + DIV_ROUND_UP(e1,e2)
> )
>
> Signed-off-by: simran singhal <singhalsimran0@...il.com>
> ---
>  drivers/staging/comedi/drivers/addi_apci_3xxx.c | 2 +-
>  drivers/staging/comedi/drivers/cb_pcidas64.c    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> index b6af3eb..82c2211 100644
> --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
> @@ -502,7 +502,7 @@ static int apci3xxx_ai_ns_to_timer(struct comedi_device *dev,
>  			timer = *ns / base;
>  			break;
>  		case CMDF_ROUND_UP:
> -			timer = (*ns + base - 1) / base;
> +			timer = DIV_ROUND_UP(*ns, base);
>  			break;
>  		}
>
> diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
> index efbf277..3b98193 100644
> --- a/drivers/staging/comedi/drivers/cb_pcidas64.c
> +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
> @@ -2007,7 +2007,7 @@ static unsigned int get_divisor(unsigned int ns, unsigned int flags)
>
>  	switch (flags & CMDF_ROUND_MASK) {
>  	case CMDF_ROUND_UP:
> -		divisor = (ns + TIMER_BASE - 1) / TIMER_BASE;
> +		divisor = DIV_ROUND_UP(ns, TIMER_BASE);
>  		break;
>  	case CMDF_ROUND_DOWN:
>  		divisor = ns / TIMER_BASE;
>

Thanks.  Ideally, this should be split into two patches, one for each 
driver module, but I guess we can live with a single patch.  (I don't 
know about the other 5 patches in this series.)

Reviewed-by: Ian Abbott <abbotti@....co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@....co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ