Re: [PATCH] dir: remove unneeded local variables from match_pathname()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Masahiro Yamada <masahiroy@xxxxxxxxxx> writes:

> The local variables are unneeded - you can simply advance the 'pathname'
> pointer.

It probably is somewhat subjective if it makes the resulting code
easier or harder to read with these extra variables, even though
"are unneeded" may technically be correct and the compilers may
produce identical binaries with or without the patch.

In the context of the original, this used to be in a loop where
elements of an array was matched against a constant pathname
variable, and it was necessary to use <name, namelen>, separate
variables, to point to the "remainder" of "pathname".  It would not
have made any sense not to use separate variables in that loop.

When the body of the loop was split into this helper function in
b5592632 (exclude: split pathname matching code into a separate
function, 2012-10-15), we could have removed these variables and
instead clobbered <pathname, pathlen>, but apparently we did not.  I
suspect that the original author found it easier to reason about the
behaviour of the function to keep the incoming parameter anchored at
the constant location, and use separate variables to point at the
tail part of the string that are to be worked on, which I tend to
disagree, but I do not have a strong preference.

Having said all that, I consider this to fall into "once the code is
written one way, it is not worth the patch noise to go and change it
to a different way." category.

Thanks.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux