compiler warnings in base
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Fix Released
|
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 (funcPtrWarning
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://
Changed in epics-base: | |
status: | Fix Committed → Fix Released |
Only in base: funcPtrWarningPatch src/dbStatic/ dbLexRoutines. c base/src/ dbStatic/ dbLexRoutines. c src/dbStatic/ dbLexRoutines. c 2005-08-29 21:14:14.000000000 +0200 dbStatic/ dbLexRoutines. c 2005-10-14 17:53:14.000000000 +0200 "gphAdd failed"); >user.data = pnewMenu;
diff -u -r base.orig/
--- base.orig/
+++ base/src/
@@ -453,7 +453,7 @@
if(!pgphentry) {
yyerrorAbort(
} else {
- pgphentry->userPvt = pnewMenu;
+ pgphentry-
}
}
@@ -682,7 +682,7 @@ "gphAdd failed"); >user.data = pdbRecordType; &pdbbase- >recordTypeList ,&pdbRecordType ->node) ; >userPvt; >user.data; pdbbase- >pgpHash, choicestring, &pdbRecordType- >devList) ; >user.data = pdevSup; &pdbRecordType- >devList, &pdevSup- >node); "gphAdd failed"); >user.data = pdrvSup; &pdbbase- >drvList, &pdrvSup- >node);
if(!pgphentry) {
yyerrorAbort(
} else {
- pgphentry->userPvt = pdbRecordType;
+ pgphentry-
}
ellAdd(
}
@@ -710,7 +710,7 @@
yyerror("Illegal link type");
return;
}
- pdbRecordType = (dbRecordType *)pgphentry-
+ pdbRecordType = (dbRecordType *)pgphentry-
pgphentry = gphFind(
if(pgphentry) {
return;
@@ -723,7 +723,7 @@
if(!pgphentry) {
yyerror("gphAdd failed");
} else {
- pgphentry->userPvt = pdevSup;
+ pgphentry-
}
ellAdd(
}
@@ -743,7 +743,7 @@
if(!pgphentry) {
yyerrorAbort(
}
- pgphentry->userPvt = pdrvSup;
+ pgphentry-
ellAdd(
}
@@ -762,7 +762,7 @@ "gphAdd failed"); >user.data = ptext; &pdbbase- >registrarList, &ptext- >node);
if(!pgphentry) {
yyerrorAbort(
}
- pgphentry->userPvt = ptext;
+ pgphentry-
ellAdd(
}
@@ -781,7 +781,7 @@
yyerrorAbort( "gphAdd failed"); >user.data = ptext; &pdbbase- >functionList, &ptext- >node);
if(!pgphentry) {
}
- pgphentry->userPvt = ptext;
+ pgphentry-
ellAdd(
}
@@ -801,7 +801,7 @@ "gphAdd failed"); >user.data = pvar; &pdbbase- >variableList, &pvar-> node);
if(!pgphentry) {
yyerrorAbort(
}
- pgphentry->userPvt = pvar;
+ pgphentry-
ellAdd(
}
@@ -891,7 +891,7 @@ "gphAdd failed"); >user.data = pnewbrkTable; &pdbbase- >bptList, &pnewbrkTable- >node); src/dbStatic/ dbStaticLib. c base/src/ dbStatic/ dbStaticLib. c src/dbStatic/ dbStaticLib. c 2004-10-11 20:17:22.000000000 +0200 dbStatic/ dbStaticLib. c 2005-10-14 17:52:24.000000000 +0200 y(pdbentry) ; pdbbase- >pgpHash, recordType, &pdbbase- >recordTypeList ); S_dbLib_ recordTypeNotFo und); >precordType = phash->userPvt; >precordType = phash->user.data;
if(!pgphentry) {
yyerrorAbort(
} else {
- pgphentry->userPvt = pnewbrkTable;
+ pgphentry-
}
if(!pbrkTable) ellAdd(
}
diff -u -r base.orig/
--- base.orig/
+++ base/src/
@@ -1251,7 +1251,7 @@
zeroDbentr
phash = gphFind(
if(!phash) return(
- pdbentry-
+ pdbentry-
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 ...