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:	Fri, 02 Aug 2013 12:15:11 +0300
From:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:	Ed Cashin <ecashin@...aid.com>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 2/2] aoe: use min() to simplify the code

On Thu, 2013-08-01 at 21:13 -0400, Ed Cashin wrote: 
> Thanks.
> 
> I agree that we could do that.  I'm not sure it increases readability to put this much stuff on one line, though.  What is the motivation?

Motivation is to explicitly show that that operation is to calculate a
minimum of two the slen parameter and the length of last part of the
disk_name.

It seems matter of taste, so, I'm okay with current piece of code.

> > min() incorporates condition in it. In our case we could do assignment and
> > make a choice at once.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> > ---
> > drivers/block/aoe/aoedev.c | 6 ++----
> > 1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
> > index db35ef6..92fadfa 100644
> > --- a/drivers/block/aoe/aoedev.c
> > +++ b/drivers/block/aoe/aoedev.c
> > @@ -13,6 +13,7 @@
> > #include <linux/kdev_t.h>
> > #include <linux/moduleparam.h>
> > #include <linux/string.h>
> > +#include <linux/kernel.h>
> > #include "aoe.h"
> > 
> > static void dummy_timer(ulong);
> > @@ -248,10 +249,7 @@ user_req(char *s, size_t slen, struct aoedev *d)
> > 	if (!d->gd)
> > 		return 0;
> > 	p = kbasename(d->gd->disk_name);
> > -	lim = sizeof(d->gd->disk_name);
> > -	lim -= p - d->gd->disk_name;
> > -	if (slen < lim)
> > -		lim = slen;
> > +	lim = min(sizeof(d->gd->disk_name) - (p - d->gd->disk_name), slen);
> > 
> > 	return !strncmp(s, p, lim);
> > }
> > -- 
> > 1.8.3.2
> > 
> 

-- 
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ