Skip to content

Commit

Permalink
Fix warning compiling with Clang 7 on ARM64:
Browse files Browse the repository at this point in the history
prefix_tree.c:158:8: error: result of comparison of constant -1 with expression of type 'char' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
  • Loading branch information
sobomax committed Oct 17, 2020
1 parent 2f18d8a commit 7330ce0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions modules/drouting/prefix_tree.c
Expand Up @@ -34,22 +34,23 @@ extern int inode;
extern int unode;

#define DR_PREFIX_ARRAY_SIZE 128
static unsigned char *dr_char2idx = NULL;
static signed char *dr_char2idx = NULL;

/* number of children under a prefix node */
int ptree_children = 0;

#define IDX_OF_CHAR(_c) \
dr_char2idx[ (unsigned char)(_c) ]
#define UIDX_OF_CHAR(_c) (unsigned char)IDX_OF_CHAR(_c)

#define IS_VALID_PREFIX_CHAR(_c) \
((((unsigned char)(_c))<DR_PREFIX_ARRAY_SIZE) && (char)IDX_OF_CHAR(_c)!=-1 )
((((unsigned char)(_c))<DR_PREFIX_ARRAY_SIZE) && IDX_OF_CHAR(_c)!=-1 )

int init_prefix_tree( char *extra_prefix_chars )
{
int i;

dr_char2idx = (unsigned char *)pkg_malloc
dr_char2idx = (signed char *)pkg_malloc
( DR_PREFIX_ARRAY_SIZE * sizeof(unsigned char) );
if (dr_char2idx==NULL) {
LM_ERR("not enought pkg mem for the prefix array\n");
Expand Down Expand Up @@ -271,9 +272,9 @@ add_prefix(
if( tmp == (prefix->s+prefix->len-1) ) {
/* last digit in the prefix string */
LM_DBG("adding info %p, %d at: "
"%p (%d)\n", r, rg, &(ptree->ptnode[IDX_OF_CHAR(*tmp)]),
"%p (%d)\n", r, rg, &(ptree->ptnode[UIDX_OF_CHAR(*tmp)]),
IDX_OF_CHAR(*tmp));
res = add_rt_info(&(ptree->ptnode[IDX_OF_CHAR(*tmp)]),
res = add_rt_info(&(ptree->ptnode[UIDX_OF_CHAR(*tmp)]),
r,rg, malloc_f, free_f);
if(res < 0 ) {
LM_ERR("adding rt info doesn't work\n");
Expand All @@ -284,13 +285,13 @@ add_prefix(
goto ok_exit;
}
/* process the current digit in the prefix */
if(NULL == ptree->ptnode[IDX_OF_CHAR(*tmp)].next) {
if(NULL == ptree->ptnode[UIDX_OF_CHAR(*tmp)].next) {
/* allocate new node */
INIT_PTREE_NODE(malloc_f, ptree,
ptree->ptnode[IDX_OF_CHAR(*tmp)].next);
ptree->ptnode[UIDX_OF_CHAR(*tmp)].next);
inode+=10;
}
ptree = ptree->ptnode[IDX_OF_CHAR(*tmp)].next;
ptree = ptree->ptnode[UIDX_OF_CHAR(*tmp)].next;
tmp++;
}

Expand Down

0 comments on commit 7330ce0

Please sign in to comment.