Skip to content

Commit 86270b3

Browse files
committed
core: make _pv_export.name str_const
This ensures that name is truly constant, stored in the read-only data segment. Use str_const_init() to initialize it consistently.
1 parent f897808 commit 86270b3

File tree

29 files changed

+239
-239
lines changed

29 files changed

+239
-239
lines changed

modules/acc/acc_mod.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ static int fixup_init_dburl(void **param);
150150
* pseudo-variables exported by acc module
151151
*/
152152
static const pv_export_t mod_items[] = {
153-
{ {"acc_extra", sizeof("acc_extra") - 1}, 2001, pv_get_acc_extra,
153+
{ str_const_init("acc_extra"), 2001, pv_get_acc_extra,
154154
pv_set_acc_extra, pv_parse_acc_extra_name,
155155
0 /* parse index(won't use here) */, 0, 0},
156-
{ {"acc_leg", sizeof("acc_leg") - 1}, 2002, pv_get_acc_leg,
156+
{ str_const_init("acc_leg"), 2002, pv_get_acc_leg,
157157
pv_set_acc_leg, pv_parse_acc_leg_name,
158158
pv_parse_acc_leg_index, 0, 0},
159-
{ {"acc_current_leg", sizeof("acc_current_leg") - 1}, 2003,
159+
{ str_const_init("acc_current_leg"), 2003,
160160
pv_get_acc_current_leg, 0, 0, 0, 0, 0},
161161
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
162162
};

modules/b2b_logic/b2b_logic.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,13 @@ static const param_export_t params[]=
292292
};
293293

294294
static const pv_export_t mod_items[] = {
295-
{{"b2b_logic.key", sizeof("b2b_logic.key") - 1}, 1000, pv_get_b2bl_key,
295+
{str_const_init("b2b_logic.key"), 1000, pv_get_b2bl_key,
296296
0, 0, 0, 0, 0},
297-
{{"b2b_logic.scenario", sizeof("b2b_logic.scenario") - 1}, 1000,
297+
{str_const_init("b2b_logic.scenario"), 1000,
298298
pv_get_scenario, 0, 0, 0, 0, 0},
299-
{{"b2b_logic.entity", sizeof("b2b_logic.entity") - 1}, 1000, pv_get_entity,
299+
{str_const_init("b2b_logic.entity"), 1000, pv_get_entity,
300300
0, pv_parse_entity_name, pv_parse_entity_index, 0, 0},
301-
{{"b2b_logic.ctx", sizeof("b2b_logic.ctx") - 1}, 1000, pv_get_ctx,
301+
{str_const_init("b2b_logic.ctx"), 1000, pv_get_ctx,
302302
pv_set_ctx, pv_parse_ctx_name, 0, 0, 0},
303303
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
304304
};

modules/benchmark/benchmark.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int bm_get_time_diff(struct sip_msg *msg, pv_param_t *param,
166166
pv_value_t *res);
167167

168168
static const pv_export_t mod_items[] = {
169-
{ {"BM_time_diff", sizeof("BM_time_diff")-1}, 1000, bm_get_time_diff, 0,
169+
{ str_const_init("BM_time_diff"), 1000, bm_get_time_diff, 0,
170170
0, 0, 0, 0 },
171171
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
172172
};

modules/call_center/call_center.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static const dep_export_t deps = {
240240
};
241241

242242
static const pv_export_t mod_pvars[] = {
243-
{ {"cc_state", sizeof("cc_state")-1}, 1000, pv_get_cc_state,
243+
{ str_const_init("cc_state"), 1000, pv_get_cc_state,
244244
0, 0, 0, 0, 0 },
245245
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
246246
};

modules/cfgutils/cfgutils.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ static const mi_export_t mi_cmds[] = {
268268
};
269269

270270
static const pv_export_t mod_items[] = {
271-
{ {"RANDOM", sizeof("RANDOM")-1}, 1000, pv_get_random_val, 0,
271+
{ str_const_init("RANDOM"), 1000, pv_get_random_val, 0,
272272
0, 0, 0, 0 },
273-
{ {"shv", (sizeof("shv")-1)}, 1001, pv_get_shvar,
273+
{ str_const_init("shv"), 1001, pv_get_shvar,
274274
pv_set_shvar, pv_parse_shvar_name, 0, 0, 0},
275-
{ {"ctime", (sizeof("ctime")-1)}, 1002, pv_get_time,
275+
{ str_const_init("ctime"), 1002, pv_get_time,
276276
0, pv_parse_time_name, 0, 0, 0},
277-
{ {"env", (sizeof("env")-1)}, 1002, pv_get_env,
277+
{ str_const_init("env"), 1002, pv_get_env,
278278
0, pv_parse_env_name, 0, 0, 0},
279279

280280
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }

modules/cgrates/cgrates.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ static const cmd_export_t cmds[] = {
102102
};
103103

104104
static const pv_export_t pvars[] = {
105-
{ str_init("cgr"), 2003, w_pv_get_cgr, w_pv_set_cgr,
105+
{ str_const_init("cgr"), 2003, w_pv_get_cgr, w_pv_set_cgr,
106106
pv_parse_cgr, pv_parse_idx_cgr, 0, 0},
107-
{ str_init("cgr_opt"), 2004, w_pv_get_cgr_opt, w_pv_set_cgr_opt,
107+
{ str_const_init("cgr_opt"), 2004, w_pv_get_cgr_opt, w_pv_set_cgr_opt,
108108
w_pv_parse_cgr, pv_parse_idx_cgr, 0, 0},
109-
{ str_init("cgr_ret"), 2005, pv_get_cgr_reply, 0,
109+
{ str_const_init("cgr_ret"), 2005, pv_get_cgr_reply, 0,
110110
pv_parse_cgr, 0, 0, 0},
111111
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
112112
};

modules/clusterer/clusterer_mod.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static const mi_export_t mi_cmds[] = {
230230

231231

232232
static const pv_export_t mod_vars[] = {
233-
{ {"cluster.sh_tag", sizeof("cluster.sh_tag")-1}, 1000, var_get_sh_tag,
233+
{ str_const_init("cluster.sh_tag"), 1000, var_get_sh_tag,
234234
var_set_sh_tag, var_parse_sh_tag_name , 0, 0, 0 },
235235
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
236236
};

modules/dialog/dialog.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -439,29 +439,29 @@ static const mi_export_t mi_cmds[] = {
439439
};
440440

441441
static const pv_export_t mod_items[] = {
442-
{ {"DLG_count", sizeof("DLG_count")-1}, 1000, pv_get_dlg_count,
442+
{ str_const_init("DLG_count"), 1000, pv_get_dlg_count,
443443
0, 0, 0, 0, 0 },
444-
{ {"DLG_lifetime",sizeof("DLG_lifetime")-1}, 1000, pv_get_dlg_lifetime,
444+
{ str_const_init("DLG_lifetime"), 1000, pv_get_dlg_lifetime,
445445
0, 0, 0, 0, 0 },
446-
{ {"DLG_status", sizeof("DLG_status")-1}, 1000, pv_get_dlg_status,
446+
{ str_const_init("DLG_status"), 1000, pv_get_dlg_status,
447447
0, 0, 0, 0, 0 },
448-
{ {"DLG_dir", sizeof("DLG_dir")-1}, 1000, pv_get_dlg_dir,
448+
{ str_const_init("DLG_dir"), 1000, pv_get_dlg_dir,
449449
0, 0, 0, 0, 0},
450-
{ {"DLG_flags", sizeof("DLG_flags")-1}, 1000, pv_get_dlg_flags,
450+
{ str_const_init("DLG_flags"), 1000, pv_get_dlg_flags,
451451
pv_set_dlg_flags, 0, 0, 0, 0 },
452-
{ {"dlg_val", sizeof("dlg_val")-1}, 1000, pv_get_dlg_val,
452+
{ str_const_init("dlg_val"), 1000, pv_get_dlg_val,
453453
pv_set_dlg_val, pv_parse_name, 0, 0, 0},
454-
{ {"DLG_did", sizeof("DLG_did")-1}, 1000, pv_get_dlg_did,
454+
{ str_const_init("DLG_did"), 1000, pv_get_dlg_did,
455455
0, 0, 0, 0, 0},
456-
{ {"DLG_end_reason", sizeof("DLG_end_reason")-1}, 1000,
456+
{ str_const_init("DLG_end_reason"), 1000,
457457
pv_get_dlg_end_reason,0,0, 0, 0, 0},
458-
{ {"DLG_timeout", sizeof("DLG_timeout")-1}, 1000,
458+
{ str_const_init("DLG_timeout"), 1000,
459459
pv_get_dlg_timeout, pv_set_dlg_timeout, 0, 0, 0, 0 },
460-
{ {"DLG_json", sizeof("DLG_json")-1}, 1000,
460+
{ str_const_init("DLG_json"), 1000,
461461
pv_get_dlg_json, 0, 0, 0, 0, 0 },
462-
{ {"DLG_ctx_json", sizeof("DLG_ctx_json")-1}, 1000,
462+
{ str_const_init("DLG_ctx_json"), 1000,
463463
pv_get_dlg_ctx_json, 0, 0, 0, 0, 0 },
464-
{ {"DLG_del_delay", sizeof("DLG_del_delay")-1}, 1000,
464+
{ str_const_init("DLG_del_delay"), 1000,
465465
pv_get_dlg_deldelay, pv_set_dlg_deldelay, 0, 0, 0, 0 },
466466
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
467467
};

modules/json/json.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ static const cmd_export_t cmds[]={
129129
};
130130

131131
static const pv_export_t mod_items[] = {
132-
{ {"json", sizeof("json")-1}, PVT_JSON, pv_get_json,
132+
{ str_const_init("json"), PVT_JSON, pv_get_json,
133133
pv_set_json, pv_parse_json_name, pv_parse_json_index, 0, 0},
134-
{ {"json_compact", sizeof("json_compact")-1}, PVT_JSON, pv_get_json_compact,
134+
{ str_const_init("json_compact"), PVT_JSON, pv_get_json_compact,
135135
pv_set_json, pv_parse_json_name, 0, 0, 0},
136-
{ {"json_pretty", sizeof("json_pretty")-1}, PVT_JSON, pv_get_json_pretty,
136+
{ str_const_init("json_pretty"), PVT_JSON, pv_get_json_pretty,
137137
pv_set_json, pv_parse_json_name, 0, 0, 0},
138138
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
139139
};

modules/nat_traversal/nat_traversal.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ static const param_export_t parameters[] = {
242242
};
243243

244244
static const pv_export_t pvars[] = {
245-
{str_init("keepalive.socket"), 1000, pv_get_keepalive_socket, NULL, pv_parse_nat_contact_name, NULL, NULL, 0},
246-
{str_init("source_uri"), 1000, pv_get_source_uri, NULL, NULL, NULL, NULL, 0},
247-
{str_init("nat_traversal.track_dialog"), 1000, pv_get_track_dialog, pv_set_track_dialog, NULL, NULL, NULL, 0},
245+
{str_const_init("keepalive.socket"), 1000, pv_get_keepalive_socket, NULL, pv_parse_nat_contact_name, NULL, NULL, 0},
246+
{str_const_init("source_uri"), 1000, pv_get_source_uri, NULL, NULL, NULL, NULL, 0},
247+
{str_const_init("nat_traversal.track_dialog"), 1000, pv_get_track_dialog, pv_set_track_dialog, NULL, NULL, NULL, 0},
248248
{{0, 0}, 0, 0, 0, 0, 0, 0, 0}
249249
};
250250

modules/presence_dfks/presence_dfks.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static char *type_values[MAX_FEATURES_NO] = {NULL,
109109
TYPE_VAL_FWD_CFA, TYPE_VAL_FWD_CFB, TYPE_VAL_FWD_CFNA};
110110

111111
static const pv_export_t mod_items[] = {
112-
{ {"dfks", sizeof("dfks")-1}, 1000, pv_get_dfks, pv_set_dfks,
112+
{ str_const_init("dfks"), 1000, pv_get_dfks, pv_set_dfks,
113113
pv_parse_dfks_name, 0, 0, 0},
114114
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
115115
};

modules/ratelimit/ratelimit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static const mi_export_t mi_cmds [] = {
194194
};
195195

196196
static const pv_export_t mod_items[] = {
197-
{ {"rl_count", sizeof("rl_count")-1}, 1010, pv_get_rl_count, 0,
197+
{ str_const_init("rl_count"), 1010, pv_get_rl_count, 0,
198198
pv_parse_rl_count, 0, 0, 0 },
199199
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
200200
};

modules/rr/rr_mod.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static const param_export_t params[] ={
135135
* pseudo-variables exported by RR module
136136
*/
137137
static const pv_export_t mod_items[] = {
138-
{ {"rr_params", sizeof("rr_params")-1}, 900, pv_get_rr_params, 0,
138+
{ str_const_init("rr_params"), 900, pv_get_rr_params, 0,
139139
0, 0, 0, 0 },
140140
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
141141
};

modules/rtp_relay/rtp_relay.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ static const param_export_t mod_params[] = {
119119
};
120120

121121
static const pv_export_t mod_pvars[] = {
122-
{ str_init("rtp_relay"), 2004, pv_get_rtp_relay_var, pv_set_rtp_relay_var,
122+
{ str_const_init("rtp_relay"), 2004, pv_get_rtp_relay_var, pv_set_rtp_relay_var,
123123
pv_parse_rtp_relay_var, pv_parse_rtp_relay_index, 0, 0},
124-
{ str_init("rtp_relay_peer"), 2005, pv_get_rtp_relay_var,
124+
{ str_const_init("rtp_relay_peer"), 2005, pv_get_rtp_relay_var,
125125
pv_set_rtp_relay_var, pv_parse_rtp_relay_var,
126126
pv_parse_rtp_relay_index, pv_init_rtp_relay_var, RTP_RELAY_PV_PEER},
127-
{ str_init("rtp_relay_ctx"), 2006, pv_get_rtp_relay_ctx,
127+
{ str_const_init("rtp_relay_ctx"), 2006, pv_get_rtp_relay_ctx,
128128
pv_set_rtp_relay_ctx, pv_parse_rtp_relay_ctx,
129129
NULL, NULL, 0},
130130
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }

modules/rtpengine/rtpengine.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,10 @@ static int pv_rtpengine_index(pv_spec_p sp, const str *in)
668668
}
669669

670670
static const pv_export_t mod_pvs[] = {
671-
{{"rtpstat", (sizeof("rtpstat")-1)}, /* RTP-Statistics */
671+
{str_const_init("rtpstat"), /* RTP-Statistics */
672672
1000, pv_get_rtpstat_f, 0, pv_parse_rtpstat,
673673
pv_rtpengine_index, pv_rtpengine_stats_used, 0},
674-
{{"rtpquery", (sizeof("rtpquery")-1)},
674+
{str_const_init("rtpquery"),
675675
1000, pv_get_rtpquery_f, 0, 0, 0, pv_rtpengine_stats_used, 0},
676676
{{0, 0}, 0, 0, 0, 0, 0, 0, 0}
677677
};

modules/signaling/signaling.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static const cmd_export_t cmds[]={
6767

6868
/** pseudo-variables exported by the module */
6969
static const pv_export_t mod_pvars[] = {
70-
{ {"sig_local_totag", sizeof("sig_local_totag") - 1}, 5003,
70+
{ str_const_init("sig_local_totag"), 5003,
7171
pv_get_local_totag, 0, 0, 0, 0, 0},
7272
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
7373
};

modules/sip_i/sip_i.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ static const trans_export_t trans[] = {
6565
};
6666

6767
static const pv_export_t mod_items[] = {
68-
{{"isup_msg_type", sizeof("isup_msg_type") - 1}, 1000, pv_get_isup_msg_type,
68+
{str_const_init("isup_msg_type"), 1000, pv_get_isup_msg_type,
6969
0, 0, 0, 0, 0},
70-
{{"isup_param", sizeof("isup_param") - 1}, 1000, pv_get_isup_param,
70+
{str_const_init("isup_param"), 1000, pv_get_isup_param,
7171
pv_set_isup_param, pv_parse_isup_param_name, pv_parse_isup_param_index, 0, 0},
72-
{{"isup_param_str", sizeof("isup_param_str") - 1}, 1000, pv_get_isup_param_str,
72+
{str_const_init("isup_param_str"), 1000, pv_get_isup_param_str,
7373
0, pv_parse_isup_param_name, 0, 0, 0},
7474
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
7575
};

modules/sipcapture/sipcapture.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -654,9 +654,9 @@ static const dep_export_t deps = {
654654
* pseudo-variables
655655
*/
656656
static const pv_export_t mod_items[] = {
657-
{{"hep_net", sizeof("hep_net")-1}, 1201, pv_get_hep_net, 0,
657+
{str_const_init("hep_net"), 1201, pv_get_hep_net, 0,
658658
pv_parse_hep_net_name, 0, 0, 0},
659-
{{"HEPVERSION", sizeof("HEPVERSION")-1}, 1202, pv_get_hep_version, 0,
659+
{str_const_init("HEPVERSION"), 1202, pv_get_hep_version, 0,
660660
0, 0, 0, 0},
661661
{{0, 0}, 0, 0, 0, 0, 0, 0, 0}
662662
};

modules/siprec/siprec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static const param_export_t params[] = {
7777
};
7878

7979
static const pv_export_t vars[] = {
80-
{ {"siprec", sizeof("siprec")-1}, 1000,
80+
{ str_const_init("siprec"), 1000,
8181
pv_get_siprec, pv_set_siprec, pv_parse_siprec,
8282
0, 0, 0 },
8383
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }

modules/sql_cacher/sql_cacher.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static const param_export_t mod_params[] = {
8181
};
8282

8383
static const pv_export_t mod_items[] = {
84-
{{"sql_cached_value", sizeof("sql_cached_value") - 1}, 1000,
84+
{str_const_init("sql_cached_value"), 1000,
8585
pv_get_sql_cached_value, 0, pv_parse_name, 0, 0, 0},
8686
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
8787
};

modules/statistics/statistics.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static const param_export_t mod_params[]={
178178

179179

180180
static const pv_export_t mod_items[] = {
181-
{ {"stat", sizeof("stat")-1}, 1100, pv_get_stat,
181+
{ str_const_init("stat"), 1100, pv_get_stat,
182182
pv_set_stat, pv_parse_name, 0, 0, 0},
183183
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
184184
};

modules/stir_shaken/stir_shaken.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static const param_export_t params[] = {
161161
};
162162

163163
static const pv_export_t mod_items[] = {
164-
{{"identity", sizeof("identity") - 1}, 1000, pv_get_identity,
164+
{str_const_init("identity"), 1000, pv_get_identity,
165165
0, pv_parse_identity_name, 0, 0, 0},
166166
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
167167
};

0 commit comments

Comments
 (0)