INN bugs with gcc 3 `bool' type

TAKAI Kousuke takai at vlsi.kuee.kyoto-u.ac.jp
Sun Dec 23 14:59:56 UTC 2001



Hello,

I found several bugs while compiling inn-CURRENT-20011205 with
gcc 3.0.2 (on a Solaris 8/sparc machine).  That is:

 - Trandindexed and buffindexed backends are using `bool' for
   return type of GROUPfilesize.  This does not matter if bool
   is defined to int, but gcc 3, which has proper bool type,
   reveals this problem (group.index always gets truncated to 1 byte).
 - lib/snprintf.c has invalid construct `va_arg (args, short int)'
   (second arg of va_arg must be a promoted type).  Recent gcc refuses
   to compile such constructs (older gcc do not complain about them,
   but silently generate wrong code on big endian machines).

Here is a patch to correct these problems, following my signature.
This patch is for CURRENT-20011205, but also applies to CURRENT-20011223.

I am not in inn-* mailing lists, so please include me to cc.
Sorry for my poor English.

-- 
 TAKAI Kousuke <takai at vlsi.kuee.kyoto-u.ac.jp>
  Dept. of Communications and Computer Engineering,
  Graduate School of Infomatics, Kyoto University, Japan

diff -ru inn-CURRENT-20011205.orig/lib/snprintf.c inn-CURRENT-20011205/lib/snprintf.c
--- inn-CURRENT-20011205.orig/lib/snprintf.c	Wed Dec  5 19:00:48 2001
+++ inn-CURRENT-20011205/lib/snprintf.c	Mon Dec 17 00:01:38 2001
@@ -298,7 +298,7 @@
       case 'd':
       case 'i':
 	if (cflags == DP_C_SHORT) 
-	  value = va_arg (args, short int);
+	  value = (short int) va_arg (args, int);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, long int);
         else if (cflags == DP_C_LLONG)
@@ -310,7 +310,7 @@
       case 'o':
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
-	  value = va_arg (args, unsigned short int);
+	  value = (unsigned short int) va_arg (args, unsigned int);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
         else if (cflags == DP_C_LLONG)
@@ -322,7 +322,7 @@
       case 'u':
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
-	  value = va_arg (args, unsigned short int);
+	  value = (unsigned short int) va_arg (args, unsigned int);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
         else if (cflags == DP_C_LLONG)
@@ -336,7 +336,7 @@
       case 'x':
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
-	  value = va_arg (args, unsigned short int);
+	  value = (unsigned short int) va_arg (args, unsigned int);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
         else if (cflags == DP_C_LLONG)
diff -ru inn-CURRENT-20011205.orig/storage/buffindexed/buffindexed.c inn-CURRENT-20011205/storage/buffindexed/buffindexed.c
--- inn-CURRENT-20011205.orig/storage/buffindexed/buffindexed.c	Wed Dec  5 19:01:03 2001
+++ inn-CURRENT-20011205/storage/buffindexed/buffindexed.c	Mon Dec 17 09:58:54 2001
@@ -243,7 +243,7 @@
 static bool GROUPLOCempty(GROUPLOC loc);
 static bool GROUPlockhash(enum inn_locktype type);
 static bool GROUPlock(GROUPLOC gloc, enum inn_locktype type);
-static bool GROUPfilesize(int count);
+static off_t GROUPfilesize(int count);
 static bool GROUPexpand(int mode);
 static void *ovopensearch(char *group, int low, int high, bool needov);
 static void ovclosesearch(void *handle, bool freeblock);
@@ -1034,8 +1034,8 @@
   return TRUE;
 }
 
-static bool GROUPfilesize(int count) {
-  return (count * sizeof(GROUPENTRY)) + sizeof(GROUPHEADER);
+static off_t GROUPfilesize(int count) {
+  return ((off_t) count * sizeof(GROUPENTRY)) + sizeof(GROUPHEADER);
 }
 
 /* Check if the given GROUPLOC refers to GROUPENTRY that we don't have mmap'ed,
diff -ru inn-CURRENT-20011205.orig/storage/ov3/ov3.c inn-CURRENT-20011205/storage/ov3/ov3.c
--- inn-CURRENT-20011205.orig/storage/ov3/ov3.c	Wed Dec  5 19:01:04 2001
+++ inn-CURRENT-20011205/storage/ov3/ov3.c	Sat Dec 22 00:14:19 2001
@@ -134,7 +134,7 @@
 static bool GROUPLOCempty(GROUPLOC loc);
 static bool GROUPlockhash(enum inn_locktype type);
 static bool GROUPlock(GROUPLOC gloc, enum inn_locktype type);
-static bool GROUPfilesize(int count);
+static off_t GROUPfilesize(int count);
 static bool GROUPexpand(int mode);
 static bool OV3packgroup(char *group, int delta);
 static GROUPHANDLE *OV3opengroup(char *group, bool needcache);
@@ -307,8 +307,8 @@
     return TRUE;
 }
 
-static bool GROUPfilesize(int count) {
-    return (count * sizeof(GROUPENTRY)) + sizeof(GROUPHEADER);
+static off_t GROUPfilesize(int count) {
+    return ((off_t)count * sizeof(GROUPENTRY)) + sizeof(GROUPHEADER);
 }
 
 /* Check if the given GROUPLOC refers to GROUPENTRY that we don't have mmap'ed,
[end of patch]


More information about the inn-bugs mailing list