Skip to content

Commit

Permalink
core: make _pv_export.name str_const
Browse files Browse the repository at this point in the history
This ensures that name is truly constant, stored in the
read-only data segment.

Use str_const_init() to initialize it consistently.
  • Loading branch information
sobomax committed Nov 15, 2023
1 parent f897808 commit 86270b3
Show file tree
Hide file tree
Showing 29 changed files with 239 additions and 239 deletions.
6 changes: 3 additions & 3 deletions modules/acc/acc_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ static int fixup_init_dburl(void **param);
* pseudo-variables exported by acc module
*/
static const pv_export_t mod_items[] = {
{ {"acc_extra", sizeof("acc_extra") - 1}, 2001, pv_get_acc_extra,
{ str_const_init("acc_extra"), 2001, pv_get_acc_extra,
pv_set_acc_extra, pv_parse_acc_extra_name,
0 /* parse index(won't use here) */, 0, 0},
{ {"acc_leg", sizeof("acc_leg") - 1}, 2002, pv_get_acc_leg,
{ str_const_init("acc_leg"), 2002, pv_get_acc_leg,
pv_set_acc_leg, pv_parse_acc_leg_name,
pv_parse_acc_leg_index, 0, 0},
{ {"acc_current_leg", sizeof("acc_current_leg") - 1}, 2003,
{ str_const_init("acc_current_leg"), 2003,
pv_get_acc_current_leg, 0, 0, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
8 changes: 4 additions & 4 deletions modules/b2b_logic/b2b_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ static const param_export_t params[]=
};

static const pv_export_t mod_items[] = {
{{"b2b_logic.key", sizeof("b2b_logic.key") - 1}, 1000, pv_get_b2bl_key,
{str_const_init("b2b_logic.key"), 1000, pv_get_b2bl_key,
0, 0, 0, 0, 0},
{{"b2b_logic.scenario", sizeof("b2b_logic.scenario") - 1}, 1000,
{str_const_init("b2b_logic.scenario"), 1000,
pv_get_scenario, 0, 0, 0, 0, 0},
{{"b2b_logic.entity", sizeof("b2b_logic.entity") - 1}, 1000, pv_get_entity,
{str_const_init("b2b_logic.entity"), 1000, pv_get_entity,
0, pv_parse_entity_name, pv_parse_entity_index, 0, 0},
{{"b2b_logic.ctx", sizeof("b2b_logic.ctx") - 1}, 1000, pv_get_ctx,
{str_const_init("b2b_logic.ctx"), 1000, pv_get_ctx,
pv_set_ctx, pv_parse_ctx_name, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
2 changes: 1 addition & 1 deletion modules/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static int bm_get_time_diff(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res);

static const pv_export_t mod_items[] = {
{ {"BM_time_diff", sizeof("BM_time_diff")-1}, 1000, bm_get_time_diff, 0,
{ str_const_init("BM_time_diff"), 1000, bm_get_time_diff, 0,
0, 0, 0, 0 },
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
2 changes: 1 addition & 1 deletion modules/call_center/call_center.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static const dep_export_t deps = {
};

static const pv_export_t mod_pvars[] = {
{ {"cc_state", sizeof("cc_state")-1}, 1000, pv_get_cc_state,
{ str_const_init("cc_state"), 1000, pv_get_cc_state,
0, 0, 0, 0, 0 },
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
8 changes: 4 additions & 4 deletions modules/cfgutils/cfgutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ static const mi_export_t mi_cmds[] = {
};

static const pv_export_t mod_items[] = {
{ {"RANDOM", sizeof("RANDOM")-1}, 1000, pv_get_random_val, 0,
{ str_const_init("RANDOM"), 1000, pv_get_random_val, 0,
0, 0, 0, 0 },
{ {"shv", (sizeof("shv")-1)}, 1001, pv_get_shvar,
{ str_const_init("shv"), 1001, pv_get_shvar,
pv_set_shvar, pv_parse_shvar_name, 0, 0, 0},
{ {"ctime", (sizeof("ctime")-1)}, 1002, pv_get_time,
{ str_const_init("ctime"), 1002, pv_get_time,
0, pv_parse_time_name, 0, 0, 0},
{ {"env", (sizeof("env")-1)}, 1002, pv_get_env,
{ str_const_init("env"), 1002, pv_get_env,
0, pv_parse_env_name, 0, 0, 0},

{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
Expand Down
6 changes: 3 additions & 3 deletions modules/cgrates/cgrates.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ static const cmd_export_t cmds[] = {
};

static const pv_export_t pvars[] = {
{ str_init("cgr"), 2003, w_pv_get_cgr, w_pv_set_cgr,
{ str_const_init("cgr"), 2003, w_pv_get_cgr, w_pv_set_cgr,
pv_parse_cgr, pv_parse_idx_cgr, 0, 0},
{ str_init("cgr_opt"), 2004, w_pv_get_cgr_opt, w_pv_set_cgr_opt,
{ str_const_init("cgr_opt"), 2004, w_pv_get_cgr_opt, w_pv_set_cgr_opt,
w_pv_parse_cgr, pv_parse_idx_cgr, 0, 0},
{ str_init("cgr_ret"), 2005, pv_get_cgr_reply, 0,
{ str_const_init("cgr_ret"), 2005, pv_get_cgr_reply, 0,
pv_parse_cgr, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
2 changes: 1 addition & 1 deletion modules/clusterer/clusterer_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static const mi_export_t mi_cmds[] = {


static const pv_export_t mod_vars[] = {
{ {"cluster.sh_tag", sizeof("cluster.sh_tag")-1}, 1000, var_get_sh_tag,
{ str_const_init("cluster.sh_tag"), 1000, var_get_sh_tag,
var_set_sh_tag, var_parse_sh_tag_name , 0, 0, 0 },
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
24 changes: 12 additions & 12 deletions modules/dialog/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,29 +439,29 @@ static const mi_export_t mi_cmds[] = {
};

static const pv_export_t mod_items[] = {
{ {"DLG_count", sizeof("DLG_count")-1}, 1000, pv_get_dlg_count,
{ str_const_init("DLG_count"), 1000, pv_get_dlg_count,
0, 0, 0, 0, 0 },
{ {"DLG_lifetime",sizeof("DLG_lifetime")-1}, 1000, pv_get_dlg_lifetime,
{ str_const_init("DLG_lifetime"), 1000, pv_get_dlg_lifetime,
0, 0, 0, 0, 0 },
{ {"DLG_status", sizeof("DLG_status")-1}, 1000, pv_get_dlg_status,
{ str_const_init("DLG_status"), 1000, pv_get_dlg_status,
0, 0, 0, 0, 0 },
{ {"DLG_dir", sizeof("DLG_dir")-1}, 1000, pv_get_dlg_dir,
{ str_const_init("DLG_dir"), 1000, pv_get_dlg_dir,
0, 0, 0, 0, 0},
{ {"DLG_flags", sizeof("DLG_flags")-1}, 1000, pv_get_dlg_flags,
{ str_const_init("DLG_flags"), 1000, pv_get_dlg_flags,
pv_set_dlg_flags, 0, 0, 0, 0 },
{ {"dlg_val", sizeof("dlg_val")-1}, 1000, pv_get_dlg_val,
{ str_const_init("dlg_val"), 1000, pv_get_dlg_val,
pv_set_dlg_val, pv_parse_name, 0, 0, 0},
{ {"DLG_did", sizeof("DLG_did")-1}, 1000, pv_get_dlg_did,
{ str_const_init("DLG_did"), 1000, pv_get_dlg_did,
0, 0, 0, 0, 0},
{ {"DLG_end_reason", sizeof("DLG_end_reason")-1}, 1000,
{ str_const_init("DLG_end_reason"), 1000,
pv_get_dlg_end_reason,0,0, 0, 0, 0},
{ {"DLG_timeout", sizeof("DLG_timeout")-1}, 1000,
{ str_const_init("DLG_timeout"), 1000,
pv_get_dlg_timeout, pv_set_dlg_timeout, 0, 0, 0, 0 },
{ {"DLG_json", sizeof("DLG_json")-1}, 1000,
{ str_const_init("DLG_json"), 1000,
pv_get_dlg_json, 0, 0, 0, 0, 0 },
{ {"DLG_ctx_json", sizeof("DLG_ctx_json")-1}, 1000,
{ str_const_init("DLG_ctx_json"), 1000,
pv_get_dlg_ctx_json, 0, 0, 0, 0, 0 },
{ {"DLG_del_delay", sizeof("DLG_del_delay")-1}, 1000,
{ str_const_init("DLG_del_delay"), 1000,
pv_get_dlg_deldelay, pv_set_dlg_deldelay, 0, 0, 0, 0 },
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
6 changes: 3 additions & 3 deletions modules/json/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ static const cmd_export_t cmds[]={
};

static const pv_export_t mod_items[] = {
{ {"json", sizeof("json")-1}, PVT_JSON, pv_get_json,
{ str_const_init("json"), PVT_JSON, pv_get_json,
pv_set_json, pv_parse_json_name, pv_parse_json_index, 0, 0},
{ {"json_compact", sizeof("json_compact")-1}, PVT_JSON, pv_get_json_compact,
{ str_const_init("json_compact"), PVT_JSON, pv_get_json_compact,
pv_set_json, pv_parse_json_name, 0, 0, 0},
{ {"json_pretty", sizeof("json_pretty")-1}, PVT_JSON, pv_get_json_pretty,
{ str_const_init("json_pretty"), PVT_JSON, pv_get_json_pretty,
pv_set_json, pv_parse_json_name, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
6 changes: 3 additions & 3 deletions modules/nat_traversal/nat_traversal.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ static const param_export_t parameters[] = {
};

static const pv_export_t pvars[] = {
{str_init("keepalive.socket"), 1000, pv_get_keepalive_socket, NULL, pv_parse_nat_contact_name, NULL, NULL, 0},
{str_init("source_uri"), 1000, pv_get_source_uri, NULL, NULL, NULL, NULL, 0},
{str_init("nat_traversal.track_dialog"), 1000, pv_get_track_dialog, pv_set_track_dialog, NULL, NULL, NULL, 0},
{str_const_init("keepalive.socket"), 1000, pv_get_keepalive_socket, NULL, pv_parse_nat_contact_name, NULL, NULL, 0},
{str_const_init("source_uri"), 1000, pv_get_source_uri, NULL, NULL, NULL, NULL, 0},
{str_const_init("nat_traversal.track_dialog"), 1000, pv_get_track_dialog, pv_set_track_dialog, NULL, NULL, NULL, 0},
{{0, 0}, 0, 0, 0, 0, 0, 0, 0}
};

Expand Down
2 changes: 1 addition & 1 deletion modules/presence_dfks/presence_dfks.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static char *type_values[MAX_FEATURES_NO] = {NULL,
TYPE_VAL_FWD_CFA, TYPE_VAL_FWD_CFB, TYPE_VAL_FWD_CFNA};

static const pv_export_t mod_items[] = {
{ {"dfks", sizeof("dfks")-1}, 1000, pv_get_dfks, pv_set_dfks,
{ str_const_init("dfks"), 1000, pv_get_dfks, pv_set_dfks,
pv_parse_dfks_name, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
2 changes: 1 addition & 1 deletion modules/ratelimit/ratelimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static const mi_export_t mi_cmds [] = {
};

static const pv_export_t mod_items[] = {
{ {"rl_count", sizeof("rl_count")-1}, 1010, pv_get_rl_count, 0,
{ str_const_init("rl_count"), 1010, pv_get_rl_count, 0,
pv_parse_rl_count, 0, 0, 0 },
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
2 changes: 1 addition & 1 deletion modules/rr/rr_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static const param_export_t params[] ={
* pseudo-variables exported by RR module
*/
static const pv_export_t mod_items[] = {
{ {"rr_params", sizeof("rr_params")-1}, 900, pv_get_rr_params, 0,
{ str_const_init("rr_params"), 900, pv_get_rr_params, 0,
0, 0, 0, 0 },
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
6 changes: 3 additions & 3 deletions modules/rtp_relay/rtp_relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ static const param_export_t mod_params[] = {
};

static const pv_export_t mod_pvars[] = {
{ str_init("rtp_relay"), 2004, pv_get_rtp_relay_var, pv_set_rtp_relay_var,
{ str_const_init("rtp_relay"), 2004, pv_get_rtp_relay_var, pv_set_rtp_relay_var,
pv_parse_rtp_relay_var, pv_parse_rtp_relay_index, 0, 0},
{ str_init("rtp_relay_peer"), 2005, pv_get_rtp_relay_var,
{ str_const_init("rtp_relay_peer"), 2005, pv_get_rtp_relay_var,
pv_set_rtp_relay_var, pv_parse_rtp_relay_var,
pv_parse_rtp_relay_index, pv_init_rtp_relay_var, RTP_RELAY_PV_PEER},
{ str_init("rtp_relay_ctx"), 2006, pv_get_rtp_relay_ctx,
{ str_const_init("rtp_relay_ctx"), 2006, pv_get_rtp_relay_ctx,
pv_set_rtp_relay_ctx, pv_parse_rtp_relay_ctx,
NULL, NULL, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
Expand Down
4 changes: 2 additions & 2 deletions modules/rtpengine/rtpengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,10 @@ static int pv_rtpengine_index(pv_spec_p sp, const str *in)
}

static const pv_export_t mod_pvs[] = {
{{"rtpstat", (sizeof("rtpstat")-1)}, /* RTP-Statistics */
{str_const_init("rtpstat"), /* RTP-Statistics */
1000, pv_get_rtpstat_f, 0, pv_parse_rtpstat,
pv_rtpengine_index, pv_rtpengine_stats_used, 0},
{{"rtpquery", (sizeof("rtpquery")-1)},
{str_const_init("rtpquery"),
1000, pv_get_rtpquery_f, 0, 0, 0, pv_rtpengine_stats_used, 0},
{{0, 0}, 0, 0, 0, 0, 0, 0, 0}
};
Expand Down
2 changes: 1 addition & 1 deletion modules/signaling/signaling.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static const cmd_export_t cmds[]={

/** pseudo-variables exported by the module */
static const pv_export_t mod_pvars[] = {
{ {"sig_local_totag", sizeof("sig_local_totag") - 1}, 5003,
{ str_const_init("sig_local_totag"), 5003,
pv_get_local_totag, 0, 0, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
6 changes: 3 additions & 3 deletions modules/sip_i/sip_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ static const trans_export_t trans[] = {
};

static const pv_export_t mod_items[] = {
{{"isup_msg_type", sizeof("isup_msg_type") - 1}, 1000, pv_get_isup_msg_type,
{str_const_init("isup_msg_type"), 1000, pv_get_isup_msg_type,
0, 0, 0, 0, 0},
{{"isup_param", sizeof("isup_param") - 1}, 1000, pv_get_isup_param,
{str_const_init("isup_param"), 1000, pv_get_isup_param,
pv_set_isup_param, pv_parse_isup_param_name, pv_parse_isup_param_index, 0, 0},
{{"isup_param_str", sizeof("isup_param_str") - 1}, 1000, pv_get_isup_param_str,
{str_const_init("isup_param_str"), 1000, pv_get_isup_param_str,
0, pv_parse_isup_param_name, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
4 changes: 2 additions & 2 deletions modules/sipcapture/sipcapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,9 @@ static const dep_export_t deps = {
* pseudo-variables
*/
static const pv_export_t mod_items[] = {
{{"hep_net", sizeof("hep_net")-1}, 1201, pv_get_hep_net, 0,
{str_const_init("hep_net"), 1201, pv_get_hep_net, 0,
pv_parse_hep_net_name, 0, 0, 0},
{{"HEPVERSION", sizeof("HEPVERSION")-1}, 1202, pv_get_hep_version, 0,
{str_const_init("HEPVERSION"), 1202, pv_get_hep_version, 0,
0, 0, 0, 0},
{{0, 0}, 0, 0, 0, 0, 0, 0, 0}
};
Expand Down
2 changes: 1 addition & 1 deletion modules/siprec/siprec.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static const param_export_t params[] = {
};

static const pv_export_t vars[] = {
{ {"siprec", sizeof("siprec")-1}, 1000,
{ str_const_init("siprec"), 1000,
pv_get_siprec, pv_set_siprec, pv_parse_siprec,
0, 0, 0 },
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
Expand Down
2 changes: 1 addition & 1 deletion modules/sql_cacher/sql_cacher.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static const param_export_t mod_params[] = {
};

static const pv_export_t mod_items[] = {
{{"sql_cached_value", sizeof("sql_cached_value") - 1}, 1000,
{str_const_init("sql_cached_value"), 1000,
pv_get_sql_cached_value, 0, pv_parse_name, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
2 changes: 1 addition & 1 deletion modules/statistics/statistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static const param_export_t mod_params[]={


static const pv_export_t mod_items[] = {
{ {"stat", sizeof("stat")-1}, 1100, pv_get_stat,
{ str_const_init("stat"), 1100, pv_get_stat,
pv_set_stat, pv_parse_name, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
2 changes: 1 addition & 1 deletion modules/stir_shaken/stir_shaken.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static const param_export_t params[] = {
};

static const pv_export_t mod_items[] = {
{{"identity", sizeof("identity") - 1}, 1000, pv_get_identity,
{str_const_init("identity"), 1000, pv_get_identity,
0, pv_parse_identity_name, 0, 0, 0},
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};
Expand Down
Loading

0 comments on commit 86270b3

Please sign in to comment.