[Scummvm-cvs-logs] CVS: scummvm/common scummsys.h,1.40,1.41

Max Horn fingolfin at users.sourceforge.net
Wed Dec 17 17:01:05 CET 2003


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv29661

Modified Files:
	scummsys.h 
Log Message:
resolve an inconsistency in the FROM_* helper macros: now they *always* cast their argument to unsigned (previously, the LE funcs would do this when used on BE machines, and vice versa; but using a FROM_LE macro on a LE machine wouldn't cause a cast to unsigned; this potentially leads to endian bugs!)

Index: scummsys.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scummsys.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- scummsys.h	8 Nov 2003 22:43:45 -0000	1.40
+++ scummsys.h	18 Dec 2003 01:00:24 -0000	1.41
@@ -306,19 +306,19 @@
 
 	#define READ_UINT32(a) READ_LE_UINT32(a)
 
-	#define FROM_LE_32(a) (a)
-	#define FROM_LE_16(a) (a)
+	#define FROM_LE_32(a) ((uint32)(a))
+	#define FROM_LE_16(a) ((uint16)(a))
 
-	#define TO_LE_32(a) (a)
-	#define TO_LE_16(a) (a)
+	#define TO_LE_32(a) ((uint32)(a))
+	#define TO_LE_16(a) ((uint16)(a))
 
 	#define TO_BE_32(a) SWAP_BYTES_32(a)
 	#define TO_BE_16(a) SWAP_BYTES_16(a)
 
 #elif defined(SCUMM_BIG_ENDIAN)
 
-	#define MKID(a) (a)
-	#define MKID_BE(a) (a)
+	#define MKID(a) ((uint32)(a))
+	#define MKID_BE(a) ((uint32)(a))
 	//#define MKID_BE(a) SWAP_BYTES_32(a)
 
 	#define READ_UINT32(a) READ_BE_UINT32(a)
@@ -329,8 +329,8 @@
 	#define TO_LE_32(a) SWAP_BYTES_32(a)
 	#define TO_LE_16(a) SWAP_BYTES_16(a)
 
-	#define TO_BE_32(a) (a)
-	#define TO_BE_16(a) (a)
+	#define TO_BE_32(a) ((uint32)(a))
+	#define TO_BE_16(a) ((uint16)(a))
 
 #else
 





More information about the Scummvm-git-logs mailing list