Subject: kern/33973: GCC4 breaks raidframe build
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <al@sigfpe.info>
List: netbsd-bugs
Date: 07/11/2006 10:30:00
>Number:         33973
>Category:       kern
>Synopsis:       GCC4 breaks raidframe build
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 11 10:30:00 +0000 2006
>Originator:     Arnaud Lacombe
>Release:        3.99.21
>Organization:
>Environment:
# uname -a #
NetBSD nov 3.0 NetBSD 3.0 (PHOENIX-XENU) #3: Tue Dec 27 00:22:18 CET 2005  root@phoenix:/mnt/tmp/kernel/XENU.obj/PHOENIX-XENU i386
>Description:
When enabling raidframe related options included in GENERIC and using GCC4, the build process fails with the followings error:

/data/work/raidframe/sys/dev/raidframe/rf_parityloggingdags.c: In function 'rf_CommonCreateParityLoggingSmallWriteDAG':
/data/work/raidframe/sys/dev/raidframe/rf_parityloggingdags.c:409: warning: passing argument 3 of 'rf_AllocBuffer' makes integer from pointer without a cast
sys/dev/raidframe/rf_parityloggingdags.c:409: error: too many arguments to function 'rf_AllocBuffer'
sys/dev/raidframe/rf_parityloggingdags.c:425: warning: passing argument 3 of 'rf_AllocBuffer' makes integer from pointer without a cast
sys/dev/raidframe/rf_parityloggingdags.c:425: error: too many arguments to function 'rf_AllocBuffer'
sys/dev/raidframe/rf_parityloggingdags.c:460: warning: assignment discards qualifiers from pointer target type
sys/dev/raidframe/rf_parityloggingdags.c:463: warning: assignment discards qualifiers from pointer target type
sys/dev/raidframe/rf_parityloggingdags.c:468: warning: assignment discards qualifiers from pointer target type
sys/dev/raidframe/rf_parityloggingdags.c:471: warning: assignment discards qualifiers from pointer target type
sys/dev/raidframe/rf_parityloggingdags.c:332: warning: unused variable 'unlockDataNodes'
sys/dev/raidframe/rf_parityloggingdags.c: In function 'rf_CreateParityLoggingSmallWriteDAG':
sys/dev/raidframe/rf_parityloggingdags.c:635: warning: passing argument 7 of 'rf_CommonCreateParityLoggingSmallWriteDAG' discards qualifiers from pointer target type

and 

warnings also happens in rf_evenodd_dagfuncs.c and rf_paritylogDiskMgr.c

The patch for rf_parityloggingdags.c has been split in two parts, one correct minor pbs (such as unused variable and 'const'), and the other one concern 'rf_AllocBuffer()' (the cast pointer -> int is wrong, as written just above the change).
>How-To-Repeat:
uncomment RF_INCLUDE_* options in kernel config file
>Fix:
Apply the following patches:

Index: sys/dev/raidframe/rf_paritylogDiskMgr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_paritylogDiskMgr.c,v
retrieving revision 1.18
diff -u -r1.18 rf_paritylogDiskMgr.c
--- sys/dev/raidframe/rf_paritylogDiskMgr.c 11 Dec 2005 12:23:37 -0000  1.18
+++ sys/dev/raidframe/rf_paritylogDiskMgr.c 10 Jul 2006 23:03:20 -0000
@@ -384,6 +384,10 @@
  RF_PhysDiskAddr_t *rrd_pda, *prd_pda, *pwr_pda;
  caddr_t parityBuffer, regionBuffer = NULL;

+ rrd_pda = NULL;
+ rrd_alloclist = NULL;
+ rrd_dag_h = NULL;
+
  /* Reintegrate a region (regionID).
   *
   * 1. acquire region and parity buffers


Index: sys/dev/raidframe/rf_evenodd_dagfuncs.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_evenodd_dagfuncs.c,v
retrieving revision 1.16
diff -u -r1.16 rf_evenodd_dagfuncs.c
--- sys/dev/raidframe/rf_evenodd_dagfuncs.c 26 Apr 2006 17:08:48 -0000  1.16
+++ sys/dev/raidframe/rf_evenodd_dagfuncs.c 10 Jul 2006 23:04:02 -0000
@@ -674,6 +674,13 @@
  RF_RowCol_t fcol[2], fsuoff[2], fsuend[2], numDataCol = layoutPtr->numDataCol;
  char  **buf, *ebuf, *pbuf, *dest[2];
  long   *suoff = NULL, *suend = NULL, *prmToCol = NULL, psuoff, esuoff;
+
+ psuoff = 0;
+ esuoff = 0;
+
+ memset(fsuoff, 0, sizeof(fsuoff));
+ memset(fsuend, 0, sizeof(fsuend));
+
  RF_SectorNum_t startSector, endSector;
  RF_Etimer_t timer;
  RF_AccTraceEntry_t *tracerec = node->dagHdr->tracerec;


Index: sys/dev/raidframe/rf_parityloggingdags.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_parityloggingdags.c,v
retrieving revision 1.15
diff -r1.15 rf_parityloggingdags.c
326c326
<     RF_RedFuncs_t * pfuncs,
---
>     const RF_RedFuncs_t * pfuncs,
332c332
<       RF_DagNode_t *unlockDataNodes = NULL, *termNode;
---
>       RF_DagNode_t *termNode;
340c340
<       char   *name, *qname;
---
>       const char   *name, *qname;
Index: sys/dev/raidframe/rf_parityloggingdags.h
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_parityloggingdags.h,v
retrieving revision 1.5
diff -r1.5 rf_parityloggingdags.h
47c47
<             RF_RedFuncs_t * pfuncs, RF_RedFuncs_t * qfuncs);
---
>             const RF_RedFuncs_t * pfuncs, RF_RedFuncs_t * qfuncs);



Index: sys/dev/raidframe/rf_parityloggingdags.c
===================================================================
RCS file: /cvsroot/src/sys/dev/raidframe/rf_parityloggingdags.c,v
retrieving revision 1.15
diff -u -r1.15 rf_parityloggingdags.c
--- sys/dev/raidframe/rf_parityloggingdags.c    11 Dec 2005 12:23:37 -0000      1.15
+++ sys/dev/raidframe/rf_parityloggingdags.c    11 Jul 2006 09:24:53 -0000
@@ -406,7 +406,10 @@
                RF_ASSERT(pda != NULL);
                readDataNodes[i].params[0].p = pda;     /* physical disk addr
                                                         * desc */
-               readDataNodes[i].params[1].p = rf_AllocBuffer(raidPtr, dag_h, pda, allocList);  /* buffer to hold old
+               /* XXX
+                * this change is certainly wrong as some arch
+                * have sizeof(void*) > sizeof(int)  */
+               readDataNodes[i].params[1].p = rf_AllocBuffer(raidPtr, dag_h, (int) pda);       /* buffer to hold old
                                                                                                 * data */
                readDataNodes[i].params[2].v = parityStripeID;
                readDataNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru);
@@ -422,7 +425,10 @@
                RF_ASSERT(pda != NULL);
                rf_InitNode(&readParityNodes[i], rf_wait, RF_FALSE, rf_DiskReadFunc, rf_DiskReadUndoFunc, rf_GenericWakeupFunc
, nNodes, 1, 4, 0, dag_h, "Rop", allocList);
                readParityNodes[i].params[0].p = pda;
-               readParityNodes[i].params[1].p = rf_AllocBuffer(raidPtr, dag_h, pda, allocList);        /* buffer to hold old
+               /* XXX
+                * this change is certainly wrong as some arch
+                * have sizeof(void*) > sizeof(int)  */
+               readParityNodes[i].params[1].p = rf_AllocBuffer(raidPtr, dag_h, (int)pda);      /* buffer to hold old
                                                                                                         * parity */
                readParityNodes[i].params[2].v = parityStripeID;
                readParityNodes[i].params[3].v = RF_CREATE_PARAM3(RF_IO_NORMAL_PRIORITY, which_ru);