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-next>] [day] [month] [year] [list]
Message-ID: <20140318131048.GA3585@infradead.org>
Date:	Tue, 18 Mar 2014 10:10:48 -0300
From:	Arnaldo Carvalho de Melo <acme@...hat.com>
To:	Namhyung Kim <namhyung@...nel.org>
Cc:	Ramkumar Ramachandra <artagnon@...il.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Jiri Olsa <jolsa@...hat.com>
Subject: Re: [PATCH 3/5] tools lib traceevent: use else-if cascade, not
 separate ifs

Em Tue, Mar 18, 2014 at 05:02:09PM +0900, Namhyung Kim escreveu:
> On Mon, 17 Mar 2014 18:26:36 -0400, Ramkumar Ramachandra wrote:
> > When token cannot be more than one value, it seems wasteful to go
> > through all the strcmp() calls. Use an else-if cascade instead.
> 
> I think the end result will be same since it returns from inside the
> block, right?

Exactly :-)

We could have it changed to something like:

	if (strcmp()) {
		ret = bla();
		goto out_free_token;
	}
.
.
.
out_free_token:
	free_token(token);
	return ret;

 
> Thanks,
> Namhyung
> 
> >
> > Cc: Steven Rostedt <rostedt@...dmis.org>
> > Cc: Namhyung Kim <namhyung@...nel.org>
> > Cc: Jiri Olsa <jolsa@...hat.com>
> > Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
> > Signed-off-by: Ramkumar Ramachandra <artagnon@...il.com>
> > ---
> >  tools/lib/traceevent/event-parse.c | 12 ++++--------
> >  1 file changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> > index 42bc571..7a8d9ae 100644
> > --- a/tools/lib/traceevent/event-parse.c
> > +++ b/tools/lib/traceevent/event-parse.c
> > @@ -2770,21 +2770,17 @@ process_function(struct event_format *event, struct print_arg *arg,
> >  		free_token(token);
> >  		is_flag_field = 1;
> >  		return process_flags(event, arg, tok);
> > -	}
> > -	if (strcmp(token, "__print_symbolic") == 0) {
> > +	} else if (strcmp(token, "__print_symbolic") == 0) {
> >  		free_token(token);
> >  		is_symbolic_field = 1;
> >  		return process_symbols(event, arg, tok);
> > -	}
> > -	if (strcmp(token, "__print_hex") == 0) {
> > +	} else if (strcmp(token, "__print_hex") == 0) {
> >  		free_token(token);
> >  		return process_hex(event, arg, tok);
> > -	}
> > -	if (strcmp(token, "__get_str") == 0) {
> > +	} else if (strcmp(token, "__get_str") == 0) {
> >  		free_token(token);
> >  		return process_str(event, arg, tok);
> > -	}
> > -	if (strcmp(token, "__get_dynamic_array") == 0) {
> > +	} else if (strcmp(token, "__get_dynamic_array") == 0) {
> >  		free_token(token);
> >  		return process_dynamic_array(event, arg, tok);
> >  	}
--
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