Re: [PATCH 0984/1285] Replace numeric parameter like 0444 with macro

From: Michal Nazarewicz
Date: Wed Aug 03 2016 - 07:16:01 EST


On Wed, Aug 03 2016, Oliver Neukum wrote:
> Before we think about that, the basic question whether
>
> S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
>
> is clearer and easier to read than
>
> 0644
>
> must be decided. I would saz no, it is not.

I was about to write the same thing.

I dislike magic numbers just like the next guy, but this replaces
a compact representation of the permissions with a long string of hard
to read, awkwardly abbreviated strings.

On personal note, I can never remember whether âuâ means user and âoâ
means other or âuâ means users and âoâ means âownerâ. In cited case
this is somehow averted because both USR and OTH are present, but what
does âS_IRWXUâ mean is a mystery to me.

To my mind, the macros make sense only when testing for particular bit
being set. Something like:

if (mode & S_IRUSR && check_if_user_can_read())
success;

could be argued as better than âmode & 0400â but even than the awkward
abbreviation doesnât help. Again, âPERM_USER_READABLEâ would be much
better (also for the reason mentioned above).

--
Best regards
ããã âðððð86â ãããããã
ÂIf at first you donât succeed, give up skydivingÂ