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: <20140720122734.GA13639@rlp>
Date:	Sun, 20 Jul 2014 14:27:34 +0200
From:	Riccardo Lucchese <riccardo.lucchese@...il.com>
To:	Dan Carpenter <dan.carpenter@...cle.com>
Cc:	gregkh@...uxfoundation.org, oleg.drokin@...el.com,
	devel@...verdev.osuosl.org, josh@...htriplett.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] staging: lustre/lustre/lov: Remove unneeded 'if'
 statement in lov_request.c/lov_check_set()

On Sun, Jul 20, 2014 at 02:37:47PM +0300, Dan Carpenter wrote:
> On Sun, Jul 20, 2014 at 01:08:36PM +0200, Riccardo Lucchese wrote:
> > Dan,
> > 
> > On Sun, Jul 20, 2014 at 07:52:53AM +0300, Dan Carpenter wrote:
> > > On Sat, Jul 19, 2014 at 09:34:56PM +0200, Riccardo Lucchese wrote:
[...]
> > > I don't see how this makes the code more readable at all.
> > 
> > Thank you for the comment. Would you consider something like the
> > following diff instead ? Otherwise, I will resend the series for
> > review without this change.
> > 
> > riccardo
> > 
> > ---
> > 
> > diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
> > index ce830e4..ae670bb 100644
> > --- a/drivers/staging/lustre/lustre/lov/lov_request.c
> > +++ b/drivers/staging/lustre/lustre/lov/lov_request.c
> > @@ -140,14 +140,14 @@ void lov_set_add_req(struct lov_request *req, struct lov_request_set *set)
> >  
> >  static int lov_check_set(struct lov_obd *lov, int idx)
> >  {
> > -	int rc = 0;
> > +	int rc;
> > +	struct lov_tgt_desc *desc;
> >  	mutex_lock(&lov->lov_lock);
> >  
> > -	if (lov->lov_tgts[idx] == NULL ||
> > -	    lov->lov_tgts[idx]->ltd_active ||
> > -	    (lov->lov_tgts[idx]->ltd_exp != NULL &&
> > -	     class_exp2cliimp(lov->lov_tgts[idx]->ltd_exp)->imp_connect_tried))
> > -		rc = 1;
> > +	desc = lov->lov_tgts[idx];
> > +	rc = !desc || desc->ltd_active ||
> > +		(desc->ltd_exp &&
> > +		 class_exp2cliimp(desc->ltd_exp)->imp_connect_tried);
> 
> Sure, I suppose.  Using "desc" is a clean up.  Otherwise the original
> code was not "silly".  It was fine.

The adjective "silly" was inappropriate and misleading, sorry about
that.

> I'm curious why you think if statements are less readable than other
> statements.  That seems like nonsense.

Not in general but, in this case, I find the patched code clearer.

Thanks,
riccardo
--
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