diff --git a/flags.c b/flags.c index 553daa71adc..2f7abfb7bc1 100644 --- a/flags.c +++ b/flags.c @@ -119,11 +119,11 @@ str bitmask_to_flag_list(enum flag_type type, int bitmask) return ret; } -int flag_list_to_bitmask(str *flags, enum flag_type type, char delim) +int flag_list_to_bitmask(const str_const *flags, enum flag_type type, char delim) { - char *p, *lim; - char *crt_flag; - str name; + const char *p, *lim; + const char *crt_flag; + str_const name; struct flag_entry *e; int ret = 0; diff --git a/flags.h b/flags.h index 5c98b0e1e19..dd894cdba15 100644 --- a/flags.h +++ b/flags.h @@ -80,7 +80,7 @@ str bitmask_to_flag_list(enum flag_type type, int bitmask); * Note: flags which are not used at script level and are not instantiated with * get_flag_id_by_name will be ignored */ -int flag_list_to_bitmask(str *flags, enum flag_type type, char delim); +int flag_list_to_bitmask(const str_const *flags, enum flag_type type, char delim); unsigned int fixup_flag(int flag_type, const str *flag_name); int get_flag_id_by_name(int flag_type, char *flag_name, int flag_name_len); diff --git a/modules/usrloc/dlist.c b/modules/usrloc/dlist.c index 1c2af0b9eb8..f7f20fe6985 100644 --- a/modules/usrloc/dlist.c +++ b/modules/usrloc/dlist.c @@ -122,7 +122,6 @@ static int get_domain_db_ucontacts(udomain_t *d, void *buf, int *len, db_res_t *res = NULL; db_row_t *row; db_val_t *val; - str flag_list; int i, no_rows = 10; time_t now; char *p, *p1; @@ -199,9 +198,10 @@ static int get_domain_db_ucontacts(udomain_t *d, void *buf, int *len, do { for (i = 0; i < RES_ROW_N(res); i++) { + str_const flag_list; row = RES_ROWS(res) + i; val = ROW_VALUES(row) + 3; /* cflags */ - flag_list.s = (char *)VAL_STRING(val); + flag_list.s = VAL_STRING(val); flag_list.len = flag_list.s ? strlen(flag_list.s) : 0; LM_DBG("contact cflags: '%.*s'\n", flag_list.len, flag_list.s); @@ -427,7 +427,7 @@ cdb_pack_ping_data(const str *aor, const cdb_pair_t *contact, break; case 'f': - cflags = flag_list_to_bitmask(&pair->val.val.st, + cflags = flag_list_to_bitmask(str2const(&pair->val.val.st), FLAG_TYPE_BRANCH, FLAG_DELIM); cols_needed &= ~COL_CFLAGS; break; diff --git a/modules/usrloc/udomain.c b/modules/usrloc/udomain.c index c482a74be72..f848a900745 100644 --- a/modules/usrloc/udomain.c +++ b/modules/usrloc/udomain.c @@ -190,7 +190,7 @@ cdb_ctdict2info(const cdb_dict_t *ct_fields, str *contact) ci.callid = &callid; break; case 'f': - ci.cflags = flag_list_to_bitmask(&pair->val.val.st, + ci.cflags = flag_list_to_bitmask(str2const(&pair->val.val.st), FLAG_TYPE_BRANCH, FLAG_DELIM); break; case 'o': @@ -271,7 +271,7 @@ static inline ucontact_info_t* dbrow2info(db_val_t *vals, str *contact) { static ucontact_info_t ci; static str callid, ua, received, host, path, instance; - static str attr, packed_kv, flags; + static str attr, packed_kv; int port, proto; char *p; @@ -323,7 +323,8 @@ static inline ucontact_info_t* dbrow2info(db_val_t *vals, str *contact) ci.flags = VAL_BITMAP(vals+6); if (!VAL_NULL(vals+7)) { - flags.s = (char *)VAL_STRING(vals+7); + str_const flags; + flags.s = VAL_STRING(vals+7); flags.len = strlen(flags.s); LM_DBG("flag str: '%.*s'\n", flags.len, flags.s); diff --git a/pvar.c b/pvar.c index 3fa93337c8e..5e1f4fa89c6 100644 --- a/pvar.c +++ b/pvar.c @@ -3243,7 +3243,7 @@ static int pv_set_branch_fields(struct sip_msg* msg, pv_param_t *param, return -1; } flags = (!val||val->flags&PV_VAL_NULL)? - 0 : flag_list_to_bitmask(&val->rs, FLAG_TYPE_BRANCH, FLAG_DELIM); + 0 : flag_list_to_bitmask(str2const(&val->rs), FLAG_TYPE_BRANCH, FLAG_DELIM); return update_branch( idx, NULL, NULL, NULL, NULL, &flags, NULL); case BR_SOCKET_ID: /* set SOCKET */