]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[libc] Ensure that error numbers from EUNIQ() have the correct type
authorMichael Brown <mcb30@ipxe.org>
Wed, 22 Sep 2010 18:59:37 +0000 (19:59 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 22 Sep 2010 19:04:11 +0000 (20:04 +0100)
Error numbers are signed ints.  EUNIQ() should not allow implicit type
promotion based on the supplied error diambiguator, because this
causes problems with statements such as

  rc = ( condition ? -EUNIQ ( EBASE, disambiguator ) : -EBASE );

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/errno.h

index 45d5382355abc384cb2a0e73a5177ac0378604aa..a86573fc9f9aaf4f4a99fc4568d5e03c0019ebc7 100644 (file)
@@ -201,7 +201,7 @@ extern char missing_errfile_declaration[] __attribute__ (( deprecated ));
  */
 #define EUNIQ( errno, uniq, ... ) ( {                                  \
        euniq_discard ( 0, ##__VA_ARGS__);                              \
-       ( (errno) | ( (uniq) << 8 ) ); } )
+       ( ( int ) ( (errno) | ( (uniq) << 8 ) ) ); } )
 static inline void euniq_discard ( int dummy __unused, ... ) {}
 
 /**