feat: add GCC/Clang function attributes for compile-time bug detection#518
Closed
somethingwithproof wants to merge 5 commits intoCacti:developfrom
Closed
feat: add GCC/Clang function attributes for compile-time bug detection#518somethingwithproof wants to merge 5 commits intoCacti:developfrom
somethingwithproof wants to merge 5 commits intoCacti:developfrom
Conversation
67438d4 to
798deb1
Compare
…RITICAL) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
798deb1 to
a1fd731
Compare
…HIGH) Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
seteuid(0) is process-wide; the previous approach of acquiring LOCK_SETEUID per-thread serialized the seteuid calls but left a window where other threads inherited euid=0 while the mutex was held. Open the ICMP raw socket once during single-threaded initialization in spine.c main(), before any worker threads start. Store it as a global (icmp_socket). ping_icmp() now dup()s that fd per call so each thread has an independent fd for select()/setsockopt()/close() without interfering with other threads. All seteuid()/LOCK_SETEUID blocks are removed from ping_icmp(). If the socket could not be opened at startup, icmp_avail is set to FALSE and the poller falls back to UDP ping as before. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
) macOS deprecated unnamed POSIX semaphores (sem_init, sem_getvalue, sem_trywait). Replace with a portable spine_sem_t wrapper using pthread mutex + condition variable. Eliminates all 9 deprecation warnings and works identically on Linux and macOS. Changes: - Add spine_sem.h with spine_sem_init/post/getvalue/wait/trywait/destroy - Replace semaphore.h with spine_sem.h in common.h - Update all sem_t/sem_* references in spine.c, poller.c, spine.h - Add spine_sem.h to EXTRA_DIST Build result: zero errors, zero warnings. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
a1fd731 to
a5e235e
Compare
Contributor
Author
|
Consolidated into mega PR #522 for independent mergeability. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
SPINE_ATTR_*compatibility macros for 6 GCC/Clang function attributes, applied across 30+ function declarations in 8 header files. Zero runtime cost; all checks happen at compile time. Gracefully compiles as no-ops on non-GCC/Clang compilers.Attributes added
SPINE_ATTR_FORMATspine_log,dieSPINE_ATTR_NORETURNdie()SPINE_ATTR_WARN_UNUSEDdb_query,exec_poll,php_cmd,snmp_get*SPINE_ATTR_NONNULLdb_query,db_insert,strncopy,snmp_get*SPINE_ATTR_PUREis_numeric,is_hexadecimal,validate_result, keyword parsersSPINE_ATTR_COLDdie()Bugs found and fixed
The
warn_unused_resultattribute ondb_query()exposed 3 memory leaks inpoller.cwhere DML queries (UPDATE/INSERT) ignored theMYSQL_RES*return value:poller.c:1945- host status updatepoller.c:1965- host polling time updatepoller.c:1983- poller items next step updateFixed by wrapping with
db_free_result(db_query(...)).Files changed (8)
spine.hutil.hsql.hpoller.hsnmp.hphp.hkeywords.hpoller.c