Skip to content

Commit

Permalink
Fix codeQL scan defects
Browse files Browse the repository at this point in the history
  • Loading branch information
EagleTw committed Jun 8, 2023
1 parent 14ed769 commit e641047
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "map.h"

/* FIXME: Avoid relying on key_size and data_size */
/* TODO: Avoid relying on key_size and data_size */
struct map_head_t {
map_node_t *root;

Expand Down Expand Up @@ -110,7 +110,7 @@ static inline void rb_node_init(map_node_t *node)
rb_node_set_right((r_node), (x_node)); \
} while (0)

/* FIXME: embed cmp (00, 01, 11) into @node pointer as 'right_red' does */
/* TODO: embed cmp (00, 01, 11) into @node pointer as 'right_red' does */
typedef struct {
map_node_t *node;
map_cmp_t cmp;
Expand All @@ -131,7 +131,7 @@ static inline map_node_t *rb_search(map_t rb, const map_node_t *node)
ret = rb_node_get_right(ret);
break;
default:
//__UNREACHABLE;
assert(0);
break;
}
}
Expand Down Expand Up @@ -159,8 +159,7 @@ static void rb_insert(map_t rb, map_node_t *node)
pathp[1].node = rb_node_get_right(pathp->node);
break;
default:
assert(cmp != _CMP_EQUAL);
//__UNREACHABLE;
/* igore duplicate key */
break;
}
}
Expand Down Expand Up @@ -230,7 +229,8 @@ static void rb_remove(map_t rb, map_node_t *node)
* The path from root to seach target is recorded in pathp[i].
*/
path->node = rb->root;
for (pathp = path; pathp->node; pathp++) {
pathp = path;
while (pathp->node) {
map_cmp_t cmp = pathp->cmp = (rb->cmp)(node->data, pathp->node->data);
if (cmp == _CMP_LESS) {
pathp[1].node = rb_node_get_left(pathp->node);
Expand All @@ -247,6 +247,7 @@ static void rb_remove(map_t rb, map_node_t *node)
break;
}
}
pathp++;
}
assert(nodep && nodep->node == node);

Expand Down
2 changes: 1 addition & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef struct map_node {
struct map_node *left, *right_red; /* red-black tree */
} map_node_t;

/* FIXME: Change to binary representation and utilize a pointer to the node
/* TODO: Change to binary representation and utilize a pointer to the node
* embedding comparator values similar to 'right_red'.
* _CMP_EQUAL : 00
* _CMP_GREATER : 01
Expand Down

0 comments on commit e641047

Please sign in to comment.