Problem
The develop branch fails to compile after the merge of several feature branches between commits 4837ddd and c03ddb0. The last known good commit is 4837ddd (fix(snmp): mark all OIDs undefined when snmp_get_multi errindex is zero).
The build fails with errors in every compilation unit, making spine uncompilable on any platform.
Root Causes
Six distinct issues were identified:
1. Missing uthash.h header (all files)
Commit c7f7724 (feat: implement O(1) hash table) added #include "uthash.h" to common.h but the header file was never committed. Every .c file fails with 'uthash.h' file not found.
2. Extra closing braces in poller.c (2 locations)
The POLLER_ACTION_SCRIPT and POLLER_ACTION_PHP_SCRIPT_SERVER case blocks each had a duplicate } inside the validate_result() error handling. This closed the switch statement prematurely, causing case/default/break to fall outside the switch.
3. Missing MYSQL_RES declaration in util.c
get_cacti_version() used result without declaring it as MYSQL_RES *result. Introduced by the dry-db-fetch refactor.
4. Stale SPINE_FREE(debug_devices) in spine.c
The uthash refactor replaced debug_devices (a char pointer) with a static hash table debug_devices_hash in util.c, but the old SPINE_FREE(debug_devices) call in spine.c was not removed.
5. SNMP_FREE macro collision with net-snmp
Spine defined its own SNMP_FREE macro in snmp.h that calls snmp_host_cleanup(), overriding net-snmp's SNMP_FREE which calls free(). This caused: (a) redefinition warnings in every compilation unit, and (b) a latent bug where errstr strings from snmp_sess_error() were passed to snmp_host_cleanup() instead of free().
6. Broken indentation in sql.c db_query()
The exponential backoff commit (2006167) broke brace nesting and indentation in db_query(), and dropped a continue statement from the lock/deadlock retry path. While not a compile error, it changes control flow behavior.
Additional Improvements
output_regex column detection (issue #210)
The output_regex feature was merged assuming the column exists in the poller_item table, but baseline Cacti does not have this column yet. Spine now uses db_column_exists() at startup to detect it and conditionally adjusts its SQL queries.
vfork deprecation in nft_popen.c
Commit b61b142 replaced vfork/execve with posix_spawn in php.c but missed nft_popen.c. Replaced with posix_spawn using the same pattern as php.c.
Fix
PR #514 addresses all six issues plus the additional improvements above. It includes:
- 16 cmocka unit tests (uthash, config init, regex_replace, strncopy)
- 21 smoke tests (SNMPv2c, SNMPv3, DB writes, multi-device)
- 15 output_regex integration tests (column absent/present/filtering/fallback)
- 16 db_column_exists integration tests (3 scenarios)
Total: 68 tests, all passing.
Problem
The
developbranch fails to compile after the merge of several feature branches between commits4837dddandc03ddb0. The last known good commit is4837ddd(fix(snmp): mark all OIDs undefined when snmp_get_multi errindex is zero).The build fails with errors in every compilation unit, making spine uncompilable on any platform.
Root Causes
Six distinct issues were identified:
1. Missing uthash.h header (all files)
Commit
c7f7724(feat: implement O(1) hash table) added#include "uthash.h"tocommon.hbut the header file was never committed. Every .c file fails with'uthash.h' file not found.2. Extra closing braces in poller.c (2 locations)
The
POLLER_ACTION_SCRIPTandPOLLER_ACTION_PHP_SCRIPT_SERVERcase blocks each had a duplicate}inside thevalidate_result()error handling. This closed theswitchstatement prematurely, causingcase/default/breakto fall outside the switch.3. Missing MYSQL_RES declaration in util.c
get_cacti_version()usedresultwithout declaring it asMYSQL_RES *result. Introduced by the dry-db-fetch refactor.4. Stale SPINE_FREE(debug_devices) in spine.c
The uthash refactor replaced
debug_devices(a char pointer) with a static hash tabledebug_devices_hashin util.c, but the oldSPINE_FREE(debug_devices)call in spine.c was not removed.5. SNMP_FREE macro collision with net-snmp
Spine defined its own
SNMP_FREEmacro insnmp.hthat callssnmp_host_cleanup(), overriding net-snmp'sSNMP_FREEwhich callsfree(). This caused: (a) redefinition warnings in every compilation unit, and (b) a latent bug whereerrstrstrings fromsnmp_sess_error()were passed tosnmp_host_cleanup()instead offree().6. Broken indentation in sql.c db_query()
The exponential backoff commit (
2006167) broke brace nesting and indentation indb_query(), and dropped acontinuestatement from the lock/deadlock retry path. While not a compile error, it changes control flow behavior.Additional Improvements
output_regex column detection (issue #210)
The output_regex feature was merged assuming the column exists in the
poller_itemtable, but baseline Cacti does not have this column yet. Spine now usesdb_column_exists()at startup to detect it and conditionally adjusts its SQL queries.vfork deprecation in nft_popen.c
Commit
b61b142replacedvfork/execvewithposix_spawninphp.cbut missednft_popen.c. Replaced withposix_spawnusing the same pattern asphp.c.Fix
PR #514 addresses all six issues plus the additional improvements above. It includes:
Total: 68 tests, all passing.