[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: open_safer on amd64
From: |
Eric Blake |
Subject: |
Re: open_safer on amd64 |
Date: |
Wed, 20 May 2009 19:00:26 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Bruno Haible on 5/20/2009 5:08 PM:
> Sergey Poznyakoff wrote:
>> When trying to compile open-safer.c on amd64 I get:
>>
>> open-safer.c: In function 'open_safer':
>> open-safer.c:46: warning: 'mode_t' is promoted to 'int' when passed through
>> '...'
>> open-safer.c:46: warning: (so you should pass 'int' not 'mode_t' to 'va_arg')
>> open-safer.c:46: note: if this code is reached, the program will abort
>
> You can ignore this warning. The code is fine.
>
> We know no way of getting rid of this warning, except by passing fewer warning
> options to gcc.
Well, we COULD file a gcc bug for being too strict on this particular
warning. In earlier versions of POSIX, the intent was that mode_t could
be narrower than int, and that all programmers had to use only symbolic
constants in that argument. But POSIX 2008 changed its stance by adding
these words:
The <sys/stat.h> header shall define the following symbolic constants for
the file mode bits encoded in type mode_t, with the indicated numeric
values. These macros shall expand to an expression which has a type that
allows them to be used, either singly or OR'ed together, as the third
argument to open() without the need for a mode_t cast. The values shall be
suitable for use in #if preprocessing directives.
which effectively requires that mode_t and int be compatible types when
passed through va_arg. POSIX 2008 also recognized traditional open-coding
(like 0660) instead of symbolic macros for mode_t values.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEUEARECAAYFAkoUp6oACgkQ84KuGfSFAYBRLgCgzrBgjhDiokTzNLIfHDD3pG8K
m6UAl0tlhBeUbwfVqY3HxB33AYdzajc=
=1AMq
-----END PGP SIGNATURE-----