gcc11 -Wall -Wpedantic cleanup (post TCL9) FUN2CD() CD2FUN()

FUN2CD() on a function pointer still raises -Wpedantic warning due to the
officially undefined behaviour as defined by C standards.

So added FUN2CD() and CD2FUN() to at least mark the call-sites to help
with identification and ignoring -Wpedantic based on the source file
context given in the compiler output.
This commit is contained in:
Darryl L. Miles 2025-01-06 16:25:15 +00:00
parent c21e182b2c
commit 48c99a7b1d
2 changed files with 10 additions and 7 deletions

View File

@ -712,11 +712,12 @@ nmwVerifyLabelFunc2(scx, label, tpath, cd)
*/
int
nmwVerifyTileFunc(tile, plane, func)
Tile *tile; /* Tile that is connected to this net. */
int plane; /* Plane index of the tile. */
int (*func)(); /* Processing function for each tile. */
nmwVerifyTileFunc(
Tile *tile, /* Tile that is connected to this net. */
int plane, /* Plane index of the tile. */
ClientData cdata) /* Processing function for each tile. */
{
int (*func)(Tile *) = (int (*)(Tile *))CD2FUN(cdata);
SearchContext scx;
char label[TERMLENGTH];
TerminalPath tpath;
@ -733,7 +734,7 @@ nmwVerifyTileFunc(tile, plane, func)
tpath.tp_next = label;
tpath.tp_last = &label[TERMLENGTH-1];
(void) DBTreeSrLabels(&scx, &DBConnectTbl[TiGetType(tile)],
0, &tpath, TF_LABEL_ATTACH, nmwVerifyLabelFunc2, (ClientData) func);
0, &tpath, TF_LABEL_ATTACH, nmwVerifyLabelFunc2, cdata);
return 0;
}
@ -764,7 +765,7 @@ nmwVerifyLabelFunc(rect, name, label, cd)
Rect *rect; /* Area of the label, in EditUse coords. */
char *name; /* Hierarchical name of label. */
Label *label; /* Actual label structure. */
ClientData cd; /* Client data for nmwVerifyTileFunc */
ClientData cd; /* Client data for nmwVerifyTileFunc (function pointer) */
{
TileTypeBitMask *mask;
int i;
@ -1287,7 +1288,7 @@ nmAllFunc(name, firstInNet, fp)
nmwVerifyCount = 0;
nmMeasureCount = 0;
(void) DBSrLabelLoc(EditCellUse, name, nmwVerifyLabelFunc,
(ClientData) nmwMeasureTileFunc);
FUN2CD(nmwMeasureTileFunc));
if (fp!=NULL)
{

View File

@ -77,9 +77,11 @@ typedef pointertype ClientData;
*/
#define CD2PTR(cd) ((void*)(cd))
#define CD2INT(cd) ((pointertype)(cd))
#define CD2FUN(cd) ((const void*)(cd))
#define PTR2CD(data) ((ClientData)(data))
#define INT2CD(data) ((ClientData)(pointertype)(data))
#define FUN2CD(data) ((ClientData)(const void*)(data))
/* --------------------------- Booleans ------------------------------- */