Re: [PATCH] compat: convert modes to use portable file type values

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

 



On Sun, Nov 30, 2014 at 3:16 PM, Torsten Bögershausen <tboegi@xxxxxx> wrote:
[snip]
> Could the code be more human-readable ?
> static inline mode_t mode_native_to_git(mode_t native_mode)
> {
>         int perm_bits = native_mode & 07777;
>         if (S_ISREG(native_mode))
>                 return 0100000 | perm_bits;
>         if (S_ISDIR(native_mode))
>                 return 0040000 | perm_bits;
>         if (S_ISLNK(native_mode))
>                 return 0120000 | perm_bits;
>         if (S_ISBLK(native_mode))
>                 return 0060000 | perm_bits;
>         if (S_ISCHR(native_mode))
>                 return 0020000 | perm_bits;
>         if (S_ISFIFO(native_mode))
>                 return 0010000 | perm_bits;
>         /* Non-standard type bits were given. */
>         /* Shouldn't we die() here ?? */
>                 return perm_bits;
> }

Sure, I can send an updated patch with the new variable and without the "else"s.

Regarding the question in the last comment:  I was assuming if this
case was ever reached, Git would handle the returned mode the same way
as if it encountered an unknown/non-standard file type on a normal
operating system, which could die() if needed in the function that
called stat().

Should I send an updated patch that die()s there?

David
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]