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

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

 



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»
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux