mirror of
https://github.com/torlando-tech/pyxis.git
synced 2026-08-28 23:00:28 +00:00
fix: make PYXIS_FILESTORE_DIAG self-contained (define bin_str)
The diagnostic patch injected printf("...%s...", bin_str(key, key_len)) into
FileStore.h but never defined bin_str, so a PYXIS_FILESTORE_DIAG=1 build failed
with an undeclared-identifier error (normal DIAG=0 builds were unaffected).
Inject a standard-C hex-encode helper as a static member alongside the prints
so the diagnostic build is self-contained. Verified: the helper compiles clean
under gnu++11 -Wall -Wextra -Werror and round-trips keys correctly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UWZuYkHBRqNb6BZHV8sTG5
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ee059e86ea
commit
a1c548dbf2
+13
-1
@@ -40,7 +40,19 @@ OLD = """\tbool exists(const uint8_t* key, uint8_t key_len)
|
||||
\t\treturn true;
|
||||
\t}"""
|
||||
|
||||
NEW = """\tbool exists(const uint8_t* key, uint8_t key_len)
|
||||
NEW = """\t// pyxis-local diagnostic helper, only compiled under PYXIS_FILESTORE_DIAG
|
||||
\t// and only used by the printfs below. Hex-encodes a binary key using just
|
||||
\t// standard C so the diagnostic build is self-contained (no external bin_str).
|
||||
\t// Static buffer is fine here: each printf evaluates it exactly once.
|
||||
\tstatic const char* bin_str(const uint8_t* d, uint8_t n) {
|
||||
\t\tstatic char b[2 * USTORE_MAX_KEY_LEN + 1];
|
||||
\t\tstatic const char hex[] = "0123456789abcdef";
|
||||
\t\tif (n > USTORE_MAX_KEY_LEN) n = USTORE_MAX_KEY_LEN;
|
||||
\t\tfor (uint8_t i = 0; i < n; i++) { b[2 * i] = hex[(d[i] >> 4) & 0xF]; b[2 * i + 1] = hex[d[i] & 0xF]; }
|
||||
\t\tb[2 * n] = '\\0';
|
||||
\t\treturn b;
|
||||
\t}
|
||||
\tbool exists(const uint8_t* key, uint8_t key_len)
|
||||
\t{
|
||||
\t\tif (!isValid()) { printf("[ustore] exists: !isValid len=%u idx_size=%zu store=%p\\n", (unsigned)key_len, _index.size(), (void*)this); return false; }
|
||||
\t\tif(key_len > USTORE_MAX_KEY_LEN) { printf("[ustore] exists: key too long\\n"); return false; }
|
||||
|
||||
Reference in New Issue
Block a user