From ab011165cd440b5535d39febd8118e3e26b64b57 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 18 Aug 2024 00:17:35 +0300 Subject: small fixes to issues reported by analyzer + Currently analyzer has to be run manually with something like make CFLAGS='-fanalyzer -Wno-analyzer-infinite-loop' I use an infinite loop as an assert, I know it's not great/technically UB but it's just a fallback. + Analyzer is still somewhat limited, I could add in more attributes about different functions, such as memory allocation sizes etc. + If I ever set up a CI pipeline, remember to use analyzer? --- src/sp_tree.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/sp_tree.c') diff --git a/src/sp_tree.c b/src/sp_tree.c index 23f707b..5166cc3 100644 --- a/src/sp_tree.c +++ b/src/sp_tree.c @@ -12,6 +12,7 @@ */ #include +#include /** * Basic BST left turn. @@ -25,6 +26,8 @@ static void __sp_turn_left(struct sp_node *n) struct sp_node *l = sp_left(n); struct sp_node *p = sp_paren(n); + assert(l); + sp_paren(l) = sp_paren(n); sp_left(n) = sp_right(l); sp_paren(n) = l; @@ -53,6 +56,8 @@ static void __sp_turn_right(struct sp_node *n) struct sp_node *r = sp_right(n); struct sp_node *p = sp_paren(n); + assert(r); + sp_paren(r) = sp_paren(n); sp_right(n) = sp_left(r); sp_paren(n) = r; -- cgit v1.3