-----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 e...@byu.net -----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-----