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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 16 Jan 2019 09:50:49 -0600
From:   Tom Zanussi <tom.zanussi@...ux.intel.com>
To:     Joe Perches <joe@...ches.com>, Tom Zanussi <zanussi@...nel.org>,
        rostedt@...dmis.org
Cc:     tglx@...utronix.de, mhiramat@...nel.org, namhyung@...nel.org,
        vedang.patel@...el.com, bigeasy@...utronix.de,
        joel@...lfernandes.org, mathieu.desnoyers@...icios.com,
        julia@...com, linux-kernel@...r.kernel.org,
        linux-rt-users@...r.kernel.org
Subject: Re: [PATCH v12 01/16] tracing: Use str_has_prefix() in
 synth_event_create()

Hi Joe,

On Tue, 2019-01-15 at 20:59 -0800, Joe Perches wrote:
> On Tue, 2019-01-15 at 16:05 -0600, Tom Zanussi wrote:
> > Since we now have a str_has_prefix() that returns the length, we
> > can
> > use that instead of explicitly calculating it.
> 
> []
> > diff --git a/kernel/trace/trace_events_hist.c
> > b/kernel/trace/trace_events_hist.c
> 
> []
> > @@ -1200,8 +1200,7 @@ static int synth_event_create(int argc, const
> > char **argv)
> >  
> >  	/* This interface accepts group name prefix */
> >  	if (strchr(name, '/')) {
> > -		len = sizeof(SYNTH_SYSTEM "/") - 1;
> > -		if (strncmp(name, SYNTH_SYSTEM "/", len))
> > +		if ((len = str_has_prefix(name, SYNTH_SYSTEM "/")) ==
> > 0)
> 
> Since this is a single test, and not multiple if/else if
> blocks, I believe this would read better on two lines
> 
> 		len = str_has_prefix(name, SYNTH_SYSTEM "/");
> 		if (len == 0)
> 
> >  			return -EINVAL;
> >  		name += len;
> >  	}
> 

And I was so happy to have finally found a legitimate reason to put an
assignment inside an if statement, sigh.  OK, I'll change it.  ;-)

Thanks,

Tom

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ