From 13f34f0effc936030baf82bbdd10285b98d6d790 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Sat, 24 Jun 2017 07:10:48 +0200 Subject: [PATCH] htable: removed useless mode param from ht_cell_value_add() - it was used only once with mode=1 --- src/modules/htable/ht_api.c | 21 ++++++++++----------- src/modules/htable/ht_api.h | 3 +-- src/modules/htable/ht_var.c | 2 +- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/modules/htable/ht_api.c b/src/modules/htable/ht_api.c index 03aee19a723..9d066eb999a 100644 --- a/src/modules/htable/ht_api.c +++ b/src/modules/htable/ht_api.c @@ -641,8 +641,7 @@ int ht_del_cell(ht_t *ht, str *name) return 0; } -ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, - ht_cell_t *old) +ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, ht_cell_t *old) { unsigned int idx; unsigned int hid; @@ -661,7 +660,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, if(ht->htexpire>0) now = time(NULL); prev = NULL; - if(mode) ht_slot_lock(ht, idx); + ht_slot_lock(ht, idx); it = ht->entries[idx].first; while(it!=NULL && it->cellid < hid) { @@ -683,7 +682,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, it->value.n = ht->initval.n; /* increment will be done below */ } else { - if(mode) ht_slot_unlock(ht, idx); + ht_slot_unlock(ht, idx); return NULL; } } @@ -691,7 +690,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, if(it->flags&AVP_VAL_STR) { /* string value cannot be incremented */ - if(mode) ht_slot_unlock(ht, idx); + ht_slot_unlock(ht, idx); return NULL; } else { it->value.n += val; @@ -702,7 +701,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, if(old->msize>=it->msize) { memcpy(old, it, it->msize); - if(mode) ht_slot_unlock(ht, idx); + ht_slot_unlock(ht, idx); return old; } } @@ -710,7 +709,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, if(cell!=NULL) memcpy(cell, it, it->msize); - if(mode) ht_slot_unlock(ht, idx); + ht_slot_unlock(ht, idx); return cell; } } @@ -720,7 +719,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, /* add val if htable has an integer init value */ if(ht->flags!=PV_VAL_INT) { - if(mode) ht_slot_unlock(ht, idx); + ht_slot_unlock(ht, idx); return NULL; } isval.n = ht->initval.n + val; @@ -728,7 +727,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, if(it == NULL) { LM_ERR("cannot create new cell.\n"); - if(mode) ht_slot_unlock(ht, idx); + ht_slot_unlock(ht, idx); return NULL; } it->expire = now + ht->htexpire; @@ -753,7 +752,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, if(old->msize>=it->msize) { memcpy(old, it, it->msize); - if(mode) ht_slot_unlock(ht, idx); + ht_slot_unlock(ht, idx); return old; } } @@ -761,7 +760,7 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, if(cell!=NULL) memcpy(cell, it, it->msize); - if(mode) ht_slot_unlock(ht, idx); + ht_slot_unlock(ht, idx); return cell; } diff --git a/src/modules/htable/ht_api.h b/src/modules/htable/ht_api.h index d64b68ac958..c9bbd68c94c 100644 --- a/src/modules/htable/ht_api.h +++ b/src/modules/htable/ht_api.h @@ -91,8 +91,7 @@ int ht_init_tables(void); int ht_destroy(void); int ht_set_cell(ht_t *ht, str *name, int type, int_str *val, int mode); int ht_del_cell(ht_t *ht, str *name); -ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, int mode, - ht_cell_t *old); +ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, ht_cell_t *old); int ht_dbg(void); ht_cell_t* ht_cell_pkg_copy(ht_t *ht, str *name, ht_cell_t *old); diff --git a/src/modules/htable/ht_var.c b/src/modules/htable/ht_var.c index 2713f41ddd6..9ef26a9e7e0 100644 --- a/src/modules/htable/ht_var.c +++ b/src/modules/htable/ht_var.c @@ -331,7 +331,7 @@ int pv_get_ht_add(struct sip_msg *msg, pv_param_t *param, LM_ERR("cannot get $sht name\n"); return -1; } - htc = ht_cell_value_add(hpv->ht, &htname, val, 1, _htc_local); + htc = ht_cell_value_add(hpv->ht, &htname, val, _htc_local); if(_htc_local!=htc) { ht_cell_pkg_free(_htc_local);