summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2026-09-03 17:01:58 -0700
committerScott Gasch <[email protected]>2026-09-03 17:01:58 -0700
commit6d76699e44f2ed0fb2368ccf0a19ae692a2d4697 (patch)
tree1984904fa82e5bc2626364e0ca28c00179938a3b /src/search.c
parent5441d2a6ce12eb4169e9d1f194a333684474dc5f (diff)
Fix all build warnings across release/DEBUG/TEST profiles
Clean gmake GENETIC=1 PERF_COUNTERS=1 MP=1 SIXTYFOUR=1 build had 100 warnings; DEBUG=1 and TEST=1 builds had more once actually exercised. - OFFSET_OF/CONTAINING_STRUCT (chess.h) and PTR_TO_ALLOC_HASH (unix.c) truncated pointers through 32-bit ULONG before use in offset/hash arithmetic on this 64-bit build -- routed through size_t instead. - Diagnostic int<->void* round-trips (command.c, root.c, split.c, sig.c, data.c, unix.c, util.c) widened/narrowed via size_t to avoid implicit truncation. - ABS_DIFF on unsigned COOR now casts to int before abs(). - Dropped -fexpensive-optimizations (GCC-only, clang silently ignores it) from GNUmakefile. - Removed genuinely dead variables (book.c, gamelist.c, split.c, testgenerate.c, testhash.c). - Guarded DEBUG/PERF_COUNTERS/_X86_-only variables and the _CMEvidenceBucket helper under the #ifdef that actually reads them, since ASSERT/EVAL_TERM/KEEP_TRACK_OF_FIRST_MOVE_FHs compile away outside those builds. - Added missing prototypes for SlidePawn, SlidePawnWithoutSigs, SlidePieceWithoutSigs (move.c), previously undeclared in chess.h. - Removed dead _SystemIsRoot (unix.c). Verified via precommit_check.sh: TEST=1 self-test suite passes, DEBUG=1 smoke test (10 random ECM positions, sd 4) passes with no crashes/assertions, release build restored -- all three profiles now build with zero warnings. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014Cmv11sJZqVfanrPh6UnWE
Diffstat (limited to 'src/search.c')
-rwxr-xr-xsrc/search.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/search.c b/src/search.c
index 6352f97..870951b 100755
--- a/src/search.c
+++ b/src/search.c
@@ -85,6 +85,7 @@ extern FLAG g_fCanSplit[MAX_PLY_PER_SEARCH];
// countermove match's own FH%? See chess.h's CM_EVIDENCE_BUCKETS
// comment. Buckets by log-ish bands rather than linear, since evidence
// values span 0 to ~STRIP_OFF_FLAGS*2 (~16.7M).
+#ifdef PERF_COUNTERS
static ULONG
_CMEvidenceBucket(ULONG uEvidence)
{
@@ -101,6 +102,7 @@ _CMEvidenceBucket(ULONG uEvidence)
}
return(0);
}
+#endif
#ifdef DEBUG
#define VERIFY_HASH_HIT \
@@ -174,8 +176,10 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx,
ULONG uNextDepth;
ULONG uLegalMoves = 0;
FLAG fIsLeftoverMove = FALSE;
+#ifdef PERF_COUNTERS
FLAG fThisMoveIsCountermoveMatch = FALSE;
ULONG uCMEvidenceBucket = 0;
+#endif
HASH_ENTRY *pHash;
FLAG fThreat;
FLAG fSkipNull;
@@ -600,6 +604,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx,
// still well-calibrated: log every countermove-
// matched move tried, bucketed by its own
// accumulated history+continuation evidence.
+#ifdef PERF_COUNTERS
fThisMoveIsCountermoveMatch = FALSE;
if ((!IS_CAPTURE_OR_PROMOTION(mv)) &&
(ctx->uPly > 0) &&
@@ -614,6 +619,7 @@ Search(IN SEARCHER_THREAD_CONTEXT *ctx,
fThisMoveIsCountermoveMatch = TRUE;
uCMEvidenceBucket = _CMEvidenceBucket(uEvidence);
}
+#endif
mv.bvFlags |= WouldGiveCheck(ctx, mv);
// Note: x is the index of the NEXT move to be
@@ -1201,7 +1207,9 @@ QSearchFromCheckNoStandPat(IN SEARCHER_THREAD_CONTEXT *ctx,
SCORE iBestScore = MATED_SCORE(ctx->uPly);
SCORE iScore;
MOVE mv;
+#if defined(DEBUG) || defined(PERF_COUNTERS)
ULONG uLegalMoves = 0;
+#endif
ULONG uQsearchCheckExtension = 0;
ASSERT(InCheck(pos, pos->uToMove));
@@ -1244,7 +1252,9 @@ QSearchFromCheckNoStandPat(IN SEARCHER_THREAD_CONTEXT *ctx,
// IDEA: prune if the side in check could have stood pat before.
if (MakeMove(ctx, mv))
{
+#if defined(DEBUG) || defined(PERF_COUNTERS)
uLegalMoves++;
+#endif
pf->uQsearchNodes++;
pf->uQsearchDepth++;
ASSERT(uQsearchCheckExtension < 3);
@@ -1331,7 +1341,9 @@ QSearch(IN SEARCHER_THREAD_CONTEXT *ctx,
SCORE iFutility;
SCORE iPositional;
ULONG x;
+#ifdef PERF_COUNTERS
ULONG uLegalMoves;
+#endif
FLAG fIncludeChecks;
FLAG fOrigStandPat = ctx->sSearchFlags.fCouldStandPat[pos->uToMove];
static ULONG _WhatToGen[] =
@@ -1467,7 +1479,9 @@ QSearch(IN SEARCHER_THREAD_CONTEXT *ctx,
GenerateMoves(ctx, NULLMOVE, _WhatToGen[fIncludeChecks]);
+#ifdef PERF_COUNTERS
uLegalMoves = 0;
+#endif
for (x = ctx->sMoveStack.uBegin[ctx->uPly];
x < ctx->sMoveStack.uEnd[ctx->uPly];
x++)
@@ -1507,7 +1521,9 @@ QSearch(IN SEARCHER_THREAD_CONTEXT *ctx,
if (MakeMove(ctx, mv))
{
+#ifdef PERF_COUNTERS
uLegalMoves++;
+#endif
pf->uQsearchNodes++;
pf->uQsearchDepth++;
ASSERT(pf->uQsearchDepth > 0);