From a4c11daa1ed2d1a25e79ec8938e93c1e8e59f7a3 Mon Sep 17 00:00:00 2001 From: Yi-Ping Pan Date: Thu, 8 Jun 2023 18:40:18 +0800 Subject: [PATCH] Fix codeQL scan defects --- src/map.c | 9 ++++----- src/map.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/map.c b/src/map.c index 3022ce6b1..f36aeaf87 100644 --- a/src/map.c +++ b/src/map.c @@ -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; @@ -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; @@ -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; } } @@ -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; } } diff --git a/src/map.h b/src/map.h index edca972cd..651cc0f98 100644 --- a/src/map.h +++ b/src/map.h @@ -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