summaryrefslogtreecommitdiff
path: root/src/unix.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/unix.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/unix.c')
-rw-r--r--src/unix.c51
1 files changed, 12 insertions, 39 deletions
diff --git a/src/unix.c b/src/unix.c
index 68d2319..d50932f 100644
--- a/src/unix.c
+++ b/src/unix.c
@@ -51,7 +51,7 @@ typedef struct _ALLOC_RECORD
} ALLOC_RECORD;
ALLOC_RECORD g_AllocHash[ALLOC_HASH_SIZE];
-#define PTR_TO_ALLOC_HASH(x) ((((ULONG)(x)) >> 3) & (ALLOC_HASH_SIZE - 1))
+#define PTR_TO_ALLOC_HASH(x) ((((ULONG)(size_t)(x)) >> 3) & (ALLOC_HASH_SIZE - 1))
ULONG
GetHeapMemoryUsage(void)
@@ -245,7 +245,7 @@ Return value:
uParam = p->uThreadParam;
i = (int)(*(p->pEntry))(uParam); // call thread's user-supplied entry
- return((void *)i);
+ return((void *)(size_t)i);
}
FLAG
@@ -344,7 +344,7 @@ Return value:
void *p;
pthread_join(q->thread, &p);
- *puCode = ((ULONG)p);
+ *puCode = ((ULONG)(size_t)p);
return(TRUE);
}
@@ -456,7 +456,7 @@ Return value:
if (0 != gettimeofday(&tv, NULL))
{
UtilPanic(UNEXPECTED_SYSTEM_CALL_FAILURE,
- NULL, "gettimeofday", (void *)errno, NULL,
+ NULL, "gettimeofday", (void *)(size_t)errno, NULL,
__FILE__, __LINE__);
}
return((double)tv.tv_sec + (double)tv.tv_usec * 1.0e-6);
@@ -489,34 +489,7 @@ Return value:
}
-static FLAG
-_SystemIsRoot(void)
-/**
-
-Routine description:
-
- This code is called by SystemDependentInitialization. Its job is to
- determine whether this process is running with administrative powers.
-
-Parameters:
-
- void
-
-Return value:
-
- static FLAG
-
-**/
-{
- if (0 == geteuid())
- {
- return(TRUE);
- }
- return(FALSE);
-}
-
-
-void FORCEINLINE
+void FORCEINLINE
SystemDeferExecution(ULONG dwMs)
/**
@@ -572,7 +545,7 @@ Return value:
if (MAP_FAILED == pMem)
{
UtilPanic(UNEXPECTED_SYSTEM_CALL_FAILURE,
- NULL, "mmap", (void *)errno, (void *)dwSizeBytes,
+ NULL, "mmap", (void *)(size_t)errno, (void *)(size_t)dwSizeBytes,
__FILE__, __LINE__);
}
(void)madvise(pMem, dwSizeBytes, MADV_RANDOM | MADV_WILLNEED);
@@ -601,7 +574,7 @@ Return value:
if (0 != munmap(pMem, (size_t)-1))
{
UtilPanic(UNEXPECTED_SYSTEM_CALL_FAILURE,
- NULL, "munmap", (void *)errno, pMem,
+ NULL, "munmap", (void *)(size_t)errno, pMem,
__FILE__, __LINE__);
}
}
@@ -628,7 +601,7 @@ Return value:
if (NULL == p)
{
UtilPanic(UNEXPECTED_SYSTEM_CALL_FAILURE,
- NULL, "malloc", (void *)errno, (void *)dwSizeBytes,
+ NULL, "malloc", (void *)(size_t)errno, (void *)(size_t)dwSizeBytes,
__FILE__, __LINE__);
}
memset(p, 0, dwSizeBytes);
@@ -706,7 +679,7 @@ Return value:
if (NULL == p)
{
UtilPanic(UNEXPECTED_SYSTEM_CALL_FAILURE,
- NULL, "mmap", (void *)errno, NULL,
+ NULL, "mmap", (void *)(size_t)errno, NULL,
__FILE__, __LINE__);
}
*p = MMAP;
@@ -718,7 +691,7 @@ Return value:
if (NULL == p)
{
UtilPanic(UNEXPECTED_SYSTEM_CALL_FAILURE,
- NULL, "malloc", (void *)errno, NULL,
+ NULL, "malloc", (void *)(size_t)errno, NULL,
__FILE__, __LINE__);
}
*p = HEAP;
@@ -832,7 +805,7 @@ Return value:
if (0 != mprotect(pMemory, dwSizeBytes, PROT_READ))
{
UtilPanic(UNEXPECTED_SYSTEM_CALL_FAILURE,
- NULL, "mprotect", (void *)errno, (void *)PROT_READ,
+ NULL, "mprotect", (void *)(size_t)errno, (void *)(size_t)PROT_READ,
__FILE__, __LINE__);
}
return(TRUE);
@@ -864,7 +837,7 @@ Return value:
UtilPanic(UNEXPECTED_SYSTEM_CALL_FAILURE,
NULL,
"mprotect",
- (void *)errno,
+ (void *)(size_t)errno,
(void *)(PROT_READ | PROT_WRITE),
__FILE__, __LINE__);
}