compiler warnings in base

Reported by Jeff Hill on 2005-10-17
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Wishlist
Unassigned

Bug Description

From Dirk,

Jeffrey O. Hill wrote:
> Dirk,
>
> There are many different compilers - and many different compiler
> versions. They all produce a different set of warnings. Compounding
> this is C++, and a lack of maturity related to what requires a warning
> and what doesnt and the relative verbosity of C++ warnings.
>
> I fix all warnings I see, but doubt that I can ever keep up with all
> of it - at least not instantaneously.
>
True. The later the compiler version number, the more warnings or even
errors. But that is the result of using the -pedantic flag ;-)

On Linux, there are very few warnings, but when I tried to build EPICS
on Windows, I found many (and different for cygwin gcc and the M$ compiler).

The problem with nonrelevant warnings is that you can't find the
relevant warnings any more.

I have built 2 patches so far for two major (nonrelevant) warnings:

1) "ISO C forbids conversion of function pointer to object pointer type"

This is a warning from cygwin gcc 3.4.4. It appears very often and means
"Thou shalt not store a function pointer in a void*".

I guess the reason is that the size of a function pointer might be
different from the size of a data pointer on some architectures. Thus it
is a portability problem. Of course it is not a problem on today's
standard architectures (PPC, x86, 68k).

I have attached a fix for this (funcPtrWarningPatch).

It basically changes in gpHash.h
  void *userPvt;
to
  union {
    void *data;
    void (*func) ();
  } user;

2) Type mismatch

The Mirco$oft cl complains a lot about type mismatch. It is mainly
signed/unsigned comparision and implicit casts to "smaller" datatypes,
also a few const/non-const casts.

The fix (typeMismatchPatch) handles that.

Please have a look at both patches if your time allows and check if I
broke someting. They are against the CVS snapshot from October 6.

There are still a few more warnings (which might be more meaningful). I
will have a look at those.

> This is probably not a mantis issue unless the problems appear to be
> liekly to cause a failure.

Most likely not.

>
> Otherwise, you could send me an e-mail if the problem appears to be
> pressing.

Not really "pressing". I just don't like to ignore warnings.

Yours
Dirk

--
Dr. Dirk Zimoch
Swiss Light Source
Paul Scherrer Institut
Computing and Controls
phone +41 56 310 5182
fax +41 56 310 4413

Original Mantis Bug: mantis-219
    http://www.aps.anl.gov/epics/mantis/view_bug_page.php?f_id=219

Tags: db Edit Tag help
Jeff Hill (johill-lanl) wrote :
Download full text (9.8 KiB)

Only in base: funcPtrWarningPatch
diff -u -r base.orig/src/dbStatic/dbLexRoutines.c base/src/dbStatic/dbLexRoutines.c
--- base.orig/src/dbStatic/dbLexRoutines.c 2005-08-29 21:14:14.000000000 +0200
+++ base/src/dbStatic/dbLexRoutines.c 2005-10-14 17:53:14.000000000 +0200
@@ -453,7 +453,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     } else {
- pgphentry->userPvt = pnewMenu;
+ pgphentry->user.data = pnewMenu;
     }
 }

@@ -682,7 +682,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     } else {
- pgphentry->userPvt = pdbRecordType;
+ pgphentry->user.data = pdbRecordType;
     }
     ellAdd(&pdbbase->recordTypeList,&pdbRecordType->node);
 }
@@ -710,7 +710,7 @@
  yyerror("Illegal link type");
  return;
     }
- pdbRecordType = (dbRecordType *)pgphentry->userPvt;
+ pdbRecordType = (dbRecordType *)pgphentry->user.data;
     pgphentry = gphFind(pdbbase->pgpHash,choicestring,&pdbRecordType->devList);
     if(pgphentry) {
  return;
@@ -723,7 +723,7 @@
     if(!pgphentry) {
  yyerror("gphAdd failed");
     } else {
- pgphentry->userPvt = pdevSup;
+ pgphentry->user.data = pdevSup;
     }
     ellAdd(&pdbRecordType->devList,&pdevSup->node);
 }
@@ -743,7 +743,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     }
- pgphentry->userPvt = pdrvSup;
+ pgphentry->user.data = pdrvSup;
     ellAdd(&pdbbase->drvList,&pdrvSup->node);
 }

@@ -762,7 +762,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     }
- pgphentry->userPvt = ptext;
+ pgphentry->user.data = ptext;
     ellAdd(&pdbbase->registrarList,&ptext->node);
 }

@@ -781,7 +781,7 @@
     if(!pgphentry) {
        yyerrorAbort("gphAdd failed");
     }
- pgphentry->userPvt = ptext;
+ pgphentry->user.data = ptext;
     ellAdd(&pdbbase->functionList,&ptext->node);
 }

@@ -801,7 +801,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     }
- pgphentry->userPvt = pvar;
+ pgphentry->user.data = pvar;
     ellAdd(&pdbbase->variableList,&pvar->node);
 }

@@ -891,7 +891,7 @@
     if(!pgphentry) {
  yyerrorAbort("gphAdd failed");
     } else {
- pgphentry->userPvt = pnewbrkTable;
+ pgphentry->user.data = pnewbrkTable;
     }
     if(!pbrkTable) ellAdd(&pdbbase->bptList,&pnewbrkTable->node);
 }
diff -u -r base.orig/src/dbStatic/dbStaticLib.c base/src/dbStatic/dbStaticLib.c
--- base.orig/src/dbStatic/dbStaticLib.c 2004-10-11 20:17:22.000000000 +0200
+++ base/src/dbStatic/dbStaticLib.c 2005-10-14 17:52:24.000000000 +0200
@@ -1251,7 +1251,7 @@
     zeroDbentry(pdbentry);
     phash = gphFind(pdbbase->pgpHash,recordType,&pdbbase->recordTypeList);
     if(!phash) return(S_dbLib_recordTypeNotFound);
- pdbentry->precordType = phash->userPvt;
+ pdbentry->precordType = phash->user.data;
     return(0);
 }

@@ -2690,7 +2690,7 @@

     pgph = gphFind(pdbbase->pgpHash,name,(void *)&pdbbase->bptList);
     if(!pgph) return(NULL);
- return((brkTable *)pgph->userPvt);
+ return((brkTable *)pgph->user.data);
 }

 dbMenu * epicsShareAPI dbFindMenu(dbBase *pdbbase,const char *name)
@@ -2699,7 +2699,7 @@

     pgph = gphFind(pdbbase->pgpHash,name,(void *)&pdbbase->menuList);
     if(!pgph) return(NULL);
- return((dbMenu ...

Read more...

Jeff Hill (johill-lanl) wrote :
Download full text (51.1 KiB)

diff -u -r base.orig/src/as/asLibRoutines.c base/src/as/asLibRoutines.c
--- base.orig/src/as/asLibRoutines.c 2004-08-27 18:18:36.000000000 +0200
+++ base/src/as/asLibRoutines.c 2005-10-15 19:29:30.000000000 +0200
@@ -335,7 +335,7 @@
 {
     ASGMEMBER *pasgmember = asMemberPvt;
     ASGCLIENT *pasgclient;
- int ind;
+ size_t ind;

     long status;
     if(!asActive) return(S_asLib_asNotActive);
@@ -1164,7 +1164,7 @@
 static long asHagAddHost(HAG *phag,const char *host)
 {
     HAGNAME *phagname;
- int ind;
+ size_t ind;

     if(!phag) return(0);
     phagname = asCalloc(1,sizeof(HAGNAME)+strlen(host)+1);
diff -u -r base.orig/src/bpt/makeBpt.c base/src/bpt/makeBpt.c
--- base.orig/src/bpt/makeBpt.c 2003-04-23 17:22:56.000000000 +0200
+++ base/src/bpt/makeBpt.c 2005-10-15 17:31:24.000000000 +0200
@@ -315,7 +315,7 @@
  *************************************************************************/

     /* Must start with table entry corresponding to engLow; */
- i = ilow;
+ i = (int) ilow;
     if (i >= ntable - 1)
  i = ntable - 2;
     rawBeg = table[i] + (table[i + 1] - table[i]) * (ilow - (double) i);
diff -u -r base.orig/src/catools/tool_lib.c base/src/catools/tool_lib.c
--- base.orig/src/catools/tool_lib.c 2004-10-19 17:17:04.000000000 +0200
+++ base/src/catools/tool_lib.c 2005-10-15 19:36:14.000000000 +0200
@@ -425,7 +425,8 @@
 void print_time_val_sts (pv* pv, unsigned long nElems)
 {
     char timeText[TIMETEXTLEN];
- int i, printAbs;
+ unsigned long i;
+ int printAbs;
     void* value = pv->value;
     epicsTimeStamp *ptsRef = &tsStart;
     epicsTimeStamp tsNow;
diff -u -r base.orig/src/db/dbAccess.c base/src/db/dbAccess.c
--- base.orig/src/db/dbAccess.c 2005-08-25 15:03:30.000000000 +0200
+++ base/src/db/dbAccess.c 2005-10-15 17:38:06.000000000 +0200
@@ -129,7 +129,7 @@
  unsigned long no_str;
  char *ptemp;
  struct dbr_enumStrs *pdbr_enumStrs=(struct dbr_enumStrs*)(*ppbuffer);
- int i;
+ unsigned long i;

  memset(pdbr_enumStrs,'\0',dbr_enumStrs_size);
  switch(field_type) {
@@ -194,8 +194,8 @@

   if(got_data) {
       struct dbr_grLong *pgr=(struct dbr_grLong*)pbuffer;
- pgr->upper_disp_limit = grd.upper_disp_limit;
- pgr->lower_disp_limit = grd.lower_disp_limit;
+ pgr->upper_disp_limit = (epicsInt32)grd.upper_disp_limit;
+ pgr->lower_disp_limit = (epicsInt32)grd.lower_disp_limit;
   } else {
       memset(pbuffer,'\0',dbr_grLong_size);
       *options = (*options) ^ DBR_GR_LONG; /*Turn off option*/
@@ -234,8 +234,8 @@

   if(got_data) {
       struct dbr_ctrlLong *pctrl=(struct dbr_ctrlLong*)pbuffer;
- pctrl->upper_ctrl_limit = ctrld.upper_ctrl_limit;
- pctrl->lower_ctrl_limit = ctrld.lower_ctrl_limit;
+ pctrl->upper_ctrl_limit = (epicsInt32)ctrld.upper_ctrl_limit;
+ pctrl->lower_ctrl_limit = (epicsInt32)ctrld.lower_ctrl_limit;
   } else {
       memset(pbuffer,'\0',dbr_ctrlLong_size);
       *options = (*options) ^ DBR_CTRL_LONG; /*Turn off option*/
@@ -275,10 +275,10 @@

   if(got_data) {
       struct dbr_alLong *pal=(struct dbr_alLong*)pbuffer;
- pal->upper_alarm_limit = ald.upper_alarm_limit;
- pal->upper_warning_limit = ald.upper_warni...

Andrew Johnson (anj) wrote :

I think these have all been fixed now.

Changed in epics-base:
status: New → Fix Committed
Andrew Johnson (anj) on 2010-11-24
Changed in epics-base:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers