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: <20181222072207.1fe78930@vmware.local.home>
Date:   Sat, 22 Dec 2018 07:22:07 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Namhyung Kim <namhyung@...nel.org>
Cc:     Joe Perches <joe@...ches.com>, LKML <linux-kernel@...r.kernel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Ingo Molnar <mingo@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Tom Zanussi <zanussi@...nel.org>, kernel-team@....com
Subject: Re: [PATCH v3] string.h: Add str_has_prefix() helper

On Sat, 22 Dec 2018 18:28:18 +0900
Namhyung Kim <namhyung@...nel.org> wrote:

> >  
> >  	for (i = 0; i < hist_data->attrs->n_actions; i++) {
> >  		str = hist_data->attrs->action_str[i];
> >  
> > -		if (str_has_prefix(str, "onmatch(")) {
> > -			char *action_str = str + sizeof("onmatch(") - 1;
> > +		if ((len = str_has_prefix(str, "onmatch("))) {
> > +			char *action_str = str + len;  
> 
> IMHO, returning (match) length might confuse people that it might
> support partial match and returns the length actually matched rather
> than full match.  If I knew it always returns the length of prefix (or
> 0) why it matters?  Using strlen() in the next line will have same
> effect of compiler optimization for the constant strings, no?
> 
> 		if (str_has_prefix(str, "onmatch(")) {
> 			char *action_str = str + strlen("onmatch(");

The reason to return the length was to get rid of the need for
duplicating the strlen("xxxx") because it's a burden to keep the two
the same. Not only that, a lot of places just do "str + 7" because it's
easier to type.

Yes, it has the same effect on the compiler, but that's not what we are
trying to solve. We are trying to get rid of the duplication, because
that requires humans to get it right, and humans are not good at that.

-- Steve

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ