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] [day] [month] [year] [list]
Date:   Sun, 23 Dec 2018 12:23:28 +0900
From:   Namhyung Kim <namhyung@...nel.org>
To:     Steven Rostedt <rostedt@...dmis.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, Dec 22, 2018 at 07:22:07AM -0500, Steven Rostedt wrote:
> 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.

Then I'm ok with that. :)

Thanks,
Namhyung

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ