r1281 - trunk/code/game

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Mar 25 23:13:30 EDT 2008


Author: thilo
Date: 2008-03-25 23:13:30 -0400 (Tue, 25 Mar 2008)
New Revision: 1281

Modified:
   trunk/code/game/bg_lib.c
Log:
Make cast-workaround to unsigned int use sizeof operator.


Modified: trunk/code/game/bg_lib.c
===================================================================
--- trunk/code/game/bg_lib.c	2008-03-25 22:06:08 UTC (rev 1280)
+++ trunk/code/game/bg_lib.c	2008-03-26 03:13:30 UTC (rev 1281)
@@ -1286,7 +1286,7 @@
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
 //	  value = (unsigned short int) va_arg (args, unsigned short int); // Thilo: This does not work because the rcc compiler cannot do that cast correctly.
-	  value = va_arg (args, unsigned int) & 0xFFFF;			  // Using this workaround instead.
+	  value = va_arg (args, unsigned int) & ( (1 << sizeof(unsigned short int) * 8) - 1); // Using this workaround instead.
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
 	else if (cflags == DP_C_LLONG)
@@ -1298,7 +1298,7 @@
       case 'u':
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
-	  value = va_arg (args, unsigned int) & 0xFFFF;
+	  value = va_arg (args, unsigned int) & ( (1 << sizeof(unsigned short int) * 8) - 1);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
 	else if (cflags == DP_C_LLONG)
@@ -1312,7 +1312,7 @@
       case 'x':
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
-	  value = va_arg (args, unsigned int) & 0xFFFF;
+	  value = va_arg (args, unsigned int) & ( (1 << sizeof(unsigned short int) * 8) - 1);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
 	else if (cflags == DP_C_LLONG)




More information about the quake3-commits mailing list