From: Brad King Date: Wed, 11 Jan 2012 13:15:20 +0000 (-0500) Subject: Cast mode constants to mode_t in case it is signed X-Git-Tag: v3.0.4~2^2~198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0889d99f1131199a293bcd0be0206982ee3a8a54;p=thirdparty%2Flibarchive.git Cast mode constants to mode_t in case it is signed At least one compiler (Borland) defines mode_t as just "short" which is signed. This breaks code like switch(archive_entry_filetype(e)) { case AE_IFREG: ... } if AE_IFREG and other constants have a longer signed type (int) because sign extension of the mode_t return type from archive_entry_filetype changes its value. Avoid the problem by ensuring the type of the constants matches mode_t. SVN-Revision: 4128 --- diff --git a/libarchive/archive_entry.h b/libarchive/archive_entry.h index 2cb1d9aec..1db2ee1f2 100644 --- a/libarchive/archive_entry.h +++ b/libarchive/archive_entry.h @@ -149,14 +149,14 @@ struct archive_entry; * portable values to platform-native values when entries are read from * or written to disk. */ -#define AE_IFMT 0170000 -#define AE_IFREG 0100000 -#define AE_IFLNK 0120000 -#define AE_IFSOCK 0140000 -#define AE_IFCHR 0020000 -#define AE_IFBLK 0060000 -#define AE_IFDIR 0040000 -#define AE_IFIFO 0010000 +#define AE_IFMT ((__LA_MODE_T)0170000) +#define AE_IFREG ((__LA_MODE_T)0100000) +#define AE_IFLNK ((__LA_MODE_T)0120000) +#define AE_IFSOCK ((__LA_MODE_T)0140000) +#define AE_IFCHR ((__LA_MODE_T)0020000) +#define AE_IFBLK ((__LA_MODE_T)0060000) +#define AE_IFDIR ((__LA_MODE_T)0040000) +#define AE_IFIFO ((__LA_MODE_T)0010000) /* * Basic object manipulation