Skip to content

Commit

Permalink
CodeQL multiple.ql EFanntenna.c DBResidueMask() call sites
Browse files Browse the repository at this point in the history
TileTypeBitMask *DBResidueMask(TileType type);
/* NOTE: candidate for using a const return */

TooManyArguments.ql EFantenna.c DBResidueMask() calls with too many args
????????.ql EFantenna. DBResidueMask() called but function return discarded
 and call has no side-effect ([[nodiscard]] candidate in C++ parlance)

This patch fixes the calling arguments to the use of DBResidueMask()
without removing the call completely (as an assessment of original
intention should be made to confirm correctness) but
this method is a access method to retrieve the residue mark

Added __nodiscard__ to function to compiler can help identify sooner
  • Loading branch information
dlmiles committed Feb 13, 2025
1 parent 79a3abe commit 9a4bf4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion database/database.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ extern TileType DBTechFindStacking();
extern bool DBIsContact();
extern PlaneMask DBLayerPlanes();

extern TileTypeBitMask *DBResidueMask();
extern __nodiscard__ TileTypeBitMask *DBResidueMask(TileType type);
extern void DBFullResidueMask();

/* Miscellaneous */
Expand Down
10 changes: 8 additions & 2 deletions extflat/EFantenna.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,10 @@ antennaAccumFunc(tile, aaptr)
{
if (type >= DBNumUserLayers)
{
DBResidueMask(type, &sMask);
/* FIXME: Remove this redundant call to DBResidueMask() ? */
/* Maybe the intention was: DBFullResidueMask(type, &sMask); */
/* But it has been called above and the sMask does not look to have been modified since */
const TileTypeBitMask *tmp = DBResidueMask(type); /* tmp unused, DBResidueMask() has no side-effects */
for (ttype = TT_TECHDEPBASE; ttype < DBNumTypes; ttype++)
if (TTMaskHasType(&sMask, ttype))
if (DBTypeOnPlane(ttype, plane))
Expand Down Expand Up @@ -983,7 +986,10 @@ antennaAccumFunc(tile, aaptr)

if (type >= DBNumUserLayers)
{
DBResidueMask(type, &sMask);
/* FIXME: Remove this redundant call to DBResidueMask() ? */
/* Maybe the intention was: DBFullResidueMask(type, &sMask); */
/* But it has been called above and the sMask does not look to have been modified since */
const TileTypeBitMask *tmp = DBResidueMask(type); /* tmp unused, DBResidueMask() has no side-effects */
for (ttype = TT_TECHDEPBASE; ttype < DBNumTypes; ttype++)
if (TTMaskHasType(&sMask, ttype))
if (DBTypeOnPlane(ttype, plane))
Expand Down

0 comments on commit 9a4bf4e

Please sign in to comment.