Skip to content

Commit

Permalink
[pua] Fix silly mixing of bits versus bytes in sizeof()
Browse files Browse the repository at this point in the history
Related to ed8bf4d

(cherry picked from commit 5610c03)
  • Loading branch information
bogdan-iancu committed Jan 31, 2023
1 parent 2095069 commit ab95174
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/pua/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ unsigned long insert_htable(ua_pres_t* presentity)
p->local_index++;
/* local_index cannot be larger than half long, to be sure it will
* not overflow the pres_id */
if (p->local_index == (1<<(sizeof(long)/2)))
if (p->local_index == (((unsigned long)1)<<(sizeof(long)*8/2))-1)
p->local_index = 0;
presentity->local_index = p->local_index;

Expand Down
6 changes: 3 additions & 3 deletions modules/pua/pua.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ static int mod_init(void)
HASH_SIZE= 512;
else {
/* must fit in half of "long" when building the pres_id */
if ( HASH_SIZE > (sizeof(long)/2) ) {
if ( HASH_SIZE > (sizeof(long)*8/2) ) {
LM_WARN("hash_size %d too large, limiting to max allowed %d\n",
HASH_SIZE, (int)(sizeof(long)/2) );
HASH_SIZE = (sizeof(long)/2);
HASH_SIZE, (int)(sizeof(long)*8/2) );
HASH_SIZE = (sizeof(long)*8/2);
}
HASH_SIZE = 1<<HASH_SIZE;
}
Expand Down

0 comments on commit ab95174

Please sign in to comment.