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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 21 Feb 2017 12:40:10 -0800
From:   Joe Perches <joe@...ches.com>
To:     simran singhal <singhalsimran0@...il.com>, oleg.drokin@...el.com
Cc:     andreas.dilger@...el.com, jsimmons@...radead.org,
        gregkh@...uxfoundation.org, lustre-devel@...ts.lustre.org,
        devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
        outreachy-kernel@...glegroups.com
Subject: Re: [PATCH 5/6] staging: lustre: Using macro DIV_ROUND_UP

On Tue, 2017-02-21 at 23:16 +0530, 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)
> )

Coccinelle scripts are great but please
inspect the results for appropriate style
and simplify the patch where possible.

> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
[]
> @@ -3136,8 +3136,7 @@ void ptlrpc_set_bulk_mbits(struct ptlrpc_request *req)
>  	 * that server can infer the number of bulks that were prepared,
>  	 * see LU-1431
>  	 */
> -	req->rq_mbits += ((bd->bd_iov_count + LNET_MAX_IOV - 1) /
> -			  LNET_MAX_IOV) - 1;
> +	req->rq_mbits += (DIV_ROUND_UP(bd->bd_iov_count, LNET_MAX_IOV)) - 1;

Unnecessary parentheses.

> diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
[]
> @@ -272,7 +272,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s,
>  static inline
>  int npages_to_npools(unsigned long npages)
>  {
> -	return (int)((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL);
> +	return (int)(DIV_ROUND_UP(npages, PAGES_PER_POOL));
>  }

Here too.

Powered by blists - more mailing lists