Source-Changes-D archive

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

Re: CVS commit: src/sys



On Tue, Apr 21, 2009 at 12:34:04AM +0000, YAMAMOTO Takashi wrote:
> 
> anyway, i don't like the "check KAUTH_GENERIC_ISSUSER first" style
> because it makes logging useless.  ie. i prefer:
> 
>       foo()
>       {
>               :
>               :
>               :
>       out:
>               /*
>                * use the power of the super user as a last resort.
>                */
>               if (error != 0) {
>                       int error2 = kauth_authorize_generic(ISSUSER);
> 
>                       if (error2 == 0) {
>                               error = 0;
>                       }
>               }
>               return error;
>       }
> 
> how do you think?

In that case you want a 'return 0' before the 'out:'.
And the 'error2' variable is pointless. So you have:

                return 0;
        out:
                if (kauth_authorize_generic(ISSUSER) != 0)
                        return error;
                return 0;

The 'all functions only have one exit' style makes reading code hard!

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index