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]
Date:   Sat, 3 Mar 2018 19:14:57 +0100
From:   Ulf Magnusson <ulfalizer@...il.com>
To:     Joey Pabalinas <joeypabalinas@...il.com>
Cc:     Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
        Arnaud Lacombe <lacombar@...il.com>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] scripts/kconfig: replace single character strcat() appends

On Sat, Mar 3, 2018 at 12:12 AM, Joey Pabalinas <joeypabalinas@...il.com> wrote:
> On Fri, Mar 02, 2018 at 02:44:53PM +0100, Ulf Magnusson wrote:
>> Not sure this is an improvement. Zeroing the bytes after the initial
>> null terminator is redundant, and the explicit '\0' makes it clearer to
>> me what's going on.
>
> Yes, I agree with you, that is definitely quite true. This along with
> the other comments you made me want to rethink this a little bit.
>
> On Fri, Mar 02, 2018 at 02:44:53PM +0100, Ulf Magnusson wrote:
>> I like the approach, but I wonder if we can take it a bit further.
>> Here's what I'd do:
>>
>>       1. Rename the 'in' parameter to 's'.
>>       2. Rename 'p' to 'in'.
>>       3. Rename 'end' to 'out'
>>
>> At that point, you're reading from 'in' and writing to 'out', which
>> seems pretty nice and readable.
>>
>> This code is pretty cold by the way, so it wouldn't matter for
>> performance. GCC knows how functions like strcat() work too, and uses
>> that to optimize (see
>> https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html).
>>
>> I'm all for trying to make Kconfig's code neater though.
>
> Since this code is pretty cold (completely agree with you there), I
> think it would actually be much more useful to rework my patch to
> have a more style-centric approach rather than an optimization-centric
> one; this code would definitely benefit from being neater.

I actually prefer the memcpy() version for style reasons, even though
it might've looked like an optimization:

With strncat(), the result string is written via both 'res' and 'end'.
With memcpy(), it's only written via the 'end'. That seems less
twisty.

Maybe this is outside the scope of the original patch, but while we're here. :)

>
> Some useful changes would be to rename of the _atrociously_ short
> identifiers like p and l.

Yeah, 'l' in particular isn't the best name, IMO ('len' is both short
and explicit, and won't be confused for 1). 'p' can be fine if it's
obvious in context (bit dubious here), but 'in' and 'out' (for 'end')
would be more informative.

's' is clear from convention to me. In general, I fully agree that you
should avoid hard-to-guess names though.

>
> Anyway I'll give that link a read over and try and make a V2 later
> on today.
>
> Appreciate the feedback, thanks for the comments!
>
> --
> Cheers,
> Joey Pabalinas

Cheers,
Ulf

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ