[PATCH] refactor correct_password.c to avoid one #if
Ralf Friedl
Ralf.Friedl at online.de
Wed Aug 1 07:39:56 UTC 2012
Tito wrote:
> On Tuesday 31 July 2012 18:08:15 walter harms wrote:
>
>> @@ -55,7 +49,10 @@ int FAST_FUNC correct_password(const struct passwd *pw)
>> }
>> correct = pw->pw_passwd;
>> #if ENABLE_FEATURE_SHADOWPASSWDS
>> + /* Using _r function to avoid pulling in static buffers */
>> if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) {
>> + struct spwd spw;
>> + char buffer[256];
>> /* getspnam_r may return 0 yet set result to NULL.
>> * At least glibc 2.4 does this. Be extra paranoid here. */
>> struct spwd *result = NULL
> I personally I'm not for mixing variable declarations and code,
> I admit tough that in this case as it are just a few lines it could be ok.
The "struct spwd *result" is already declared inside the block, so it's
just consequent to move the other declarations there, too.
I personally like to have the variables declared in the block where they
are used, because it makes it immediately clear to the reader that they
are used only in that block.
Ralf
More information about the busybox
mailing list