remove all uses of XXXSUPFUN typedefs
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
EPICS Base |
Fix Released
|
Wishlist
|
Ben Franksen |
Bug Description
The OO-like function tables defined in recSup.h, devSup.h, and drvSup.h disable type checking by using the typedefs RECSUPFUN, DEVSUPFUN, and DRVSUPFUN, respectively, which declare the methods as having "any number and type of arguments". For instance, this is in devSup.h:
typedef long (*DRVSUPFUN) (); /* ptr to driver support function*/
typedef struct drvet { /* driver entry table */
long number; /*number of support routines*/
DRVSUPFUN report; /*print report*/
DRVSUPFUN init; /*init support*/
}drvet;
Supports have to uses casts to XXXSUPFUN when they fill a xxxet structure.
I think listing the well-known reasons why this is bad would be redundant. As an illustration, see the bug recently uncovered by Carsten Winkler (http://
I propose to change the definition of these structs so that all the methods get their proper type.
There remains the question how to handle the (implicit) subtype polymorphism for things like dbCommon. I propose to handle this by forcing support definitions to explicitly cast the argument (e.g. dbCommon *precord) to the appropriate subtype; this adds one line of code to each support function e.g.
long process(dbCommon *pdbCommon)
{
aoRecord *prec = (aoRecord *)pdbCommon;
...use prec from here onward...
}
Related branches
Changed in epics-base: | |
assignee: | nobody → Ben Franksen (bfrk) |
status: | Triaged → In Progress |
I've certainly been bitten by this before. The problem is how to change this is a backwards compatible way. That is, how not to break existing device support code which uses these definitions. Accomplishing this for both C and C++ seems a less than straight forward task.
You might be interested in looking at, or working on, lp:~epics-core/epics-base/dtypedset which tries to solve this problem.