enclose macro arguments in parenthesis

Sun, 23 Oct 2022 13:32:16 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 23 Oct 2022 13:32:16 +0200
changeset 592
bb69ef3ad1f3
parent 591
7df0bcaecffa
child 593
ea9b41b5ebbc

enclose macro arguments in parenthesis

src/linked_list.c file | annotate | diff | comparison | revisions
src/tree.c file | annotate | diff | comparison | revisions
--- a/src/linked_list.c	Tue Oct 04 19:25:07 2022 +0200
+++ b/src/linked_list.c	Sun Oct 23 13:32:16 2022 +0200
@@ -34,11 +34,11 @@
 
 /* LOW LEVEL LINKED LIST FUNCTIONS */
 
-#define CX_LL_PTR(cur, off) (*(void**)(((char*)cur)+off))
+#define CX_LL_PTR(cur, off) (*(void**)(((char*)(cur))+(off)))
 #define ll_prev(node) CX_LL_PTR(node, loc_prev)
 #define ll_next(node) CX_LL_PTR(node, loc_next)
 #define ll_advance(node) CX_LL_PTR(node, loc_advance)
-#define ll_data_f(node, follow_ptr) ((follow_ptr)?CX_LL_PTR(node, loc_data):(((char*)node)+loc_data))
+#define ll_data_f(node, follow_ptr) ((follow_ptr)?CX_LL_PTR(node, loc_data):(((char*)(node))+loc_data))
 #define ll_data(node) ll_data_f(node,follow_ptr)
 
 void *cx_linked_list_at(
--- a/src/tree.c	Tue Oct 04 19:25:07 2022 +0200
+++ b/src/tree.c	Sun Oct 23 13:32:16 2022 +0200
@@ -29,7 +29,7 @@
 #include "cx/tree.h"
 #include "cx/linked_list.h"
 
-#define CX_TR_PTR(cur, off) *((void**)(((char*)cur)+off))
+#define CX_TR_PTR(cur, off) *((void**)(((char*)(cur))+(off)))
 
 void cx_tree_add_sibling(void *node, ptrdiff_t loc_prev, ptrdiff_t loc_next, ptrdiff_t loc_parent, void *new_node) {
     cx_linked_list_add(&node, NULL, loc_prev, loc_next, new_node);

mercurial