rb_tree icon indicating copy to clipboard operation
rb_tree copied to clipboard

rb_tree_insert_node doesn't return a success indicator correctly

Open SeanHeelan opened this issue 6 years ago • 1 comments

The function starts as follows:

232 // Returns 1 on success, 0 otherwise.                                            
233 int                                                                              
234 rb_tree_insert_node (struct rb_tree *self, struct rb_node *node) {               
235     int result = 0;

But simply returns 1 at the end. The result variable isn't used, which generates a compiler warning from gcc

cc -O3 -funroll-loops -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign -fPIC -c rb_tree.c -o rb_tree.o
rb_tree.c: In function ‘rb_tree_insert_node’:
rb_tree.c:235:9: warning: variable ‘result’ set but not used [-Wunused-but-set-variable]
     int result = 0;
         ^~~~~~

SeanHeelan avatar Oct 26 '18 17:10 SeanHeelan

Given the age of this repository, it is unlikely that this will be addressed, but I would note that there are a number of instances where functions will silently return when invalid parameters are passed. As for the specific issue that you note, it did not appear to have been fixed in any forks of this code - As such, I have created a new fork created a pull request #1 with this trivial change.

61131 avatar Dec 03 '18 22:12 61131