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

Re: mode_t bitwise operations different under kFreeBSD?



It is roughly equal to this:

void foo(unsigned short int a)
{
   a = (( a & (~0x1F)) | 0x10);
}

It seems to me that the S_* constants should have the same type as mode_t, so it's not quite the same...

The "~S_IFMT" is not a constant.

See also 6.3.1 in ISO/IEC 9899 - Programming languages - C, namely "integer promotions".

This code will warn also under Linux.

Do you mean the fragment above or the original code? Because the original code produces problems only on kFreeBSD, see https://buildd.debian.org/status/package.php?p=python-llfuse

The fragment above, because

Linux:    mode_t is unsigned int
FreeBSD:  mode_t is short unsigned int

Again please see "unsigned short" x "signed int".

Or also try to compile with "-Wconversion -Werror" just
**
unsigned short a = ~0x1F;
**

Petr


Reply to: