Skip to content

Commit e470daa

Browse files
committed
Make appropriate fields of the module_exports const.
1 parent 6e03e9f commit e470daa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+151
-148
lines changed

action.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ int do_action(struct action* a, struct sip_msg* msg)
622622
pv_value_t val;
623623
struct timeval start;
624624
int end_time;
625-
cmd_export_t *cmd = NULL;
625+
const cmd_export_t *cmd = NULL;
626626
acmd_export_t *acmd;
627627
void* cmdp[MAX_CMD_PARAMS];
628628
pv_value_t tmp_vals[MAX_CMD_PARAMS];
@@ -1026,7 +1026,7 @@ int do_action(struct action* a, struct sip_msg* msg)
10261026
break;
10271027
case CMD_T:
10281028
if (a->elem[0].type != CMD_ST ||
1029-
((cmd = (cmd_export_t*)a->elem[0].u.data) == NULL)) {
1029+
((cmd = (const cmd_export_t*)a->elem[0].u.data) == NULL)) {
10301030
LM_ALERT("BUG in module call\n");
10311031
break;
10321032
}

cmds.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
#include "cmds.h"
2323

24-
cmd_export_t* find_cmd_export_t(char* name, int flags)
24+
const cmd_export_t* find_cmd_export_t(const char* name, int flags)
2525
{
26-
cmd_export_t* cmd;
26+
const cmd_export_t* cmd;
2727

2828
cmd = find_core_cmd_export_t(name, flags);
2929
if (!cmd)
@@ -40,9 +40,9 @@ cmd_export_t* find_cmd_export_t(char* name, int flags)
4040
* -2 - too many parameters
4141
* -3 - mandatory parameter omitted
4242
*/
43-
int check_cmd_call_params(cmd_export_t *cmd, action_elem_t *elems, int no_params)
43+
int check_cmd_call_params(const cmd_export_t *cmd, action_elem_t *elems, int no_params)
4444
{
45-
struct cmd_param *param;
45+
const struct cmd_param *param;
4646
int n=0, m=0, i;
4747

4848
for (param=cmd->params; param->flags; param++, n++)

cmds.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ struct acmd_export_ {
7474
typedef struct cmd_export_ cmd_export_t;
7575
typedef struct acmd_export_ acmd_export_t;
7676

77-
cmd_export_t* find_cmd_export_t(char* name, int flags);
78-
int check_cmd_call_params(cmd_export_t *cmd, action_elem_t *elems, int no_params);
77+
const cmd_export_t* find_cmd_export_t(const char* name, int flags);
78+
int check_cmd_call_params(const cmd_export_t *cmd, action_elem_t *elems, int no_params);
7979
int check_acmd_call_params(acmd_export_t *acmd, action_elem_t *elems, int no_params);
8080

81-
cmd_export_t* find_core_cmd_export_t(char* name, int flags);
82-
cmd_export_t* find_mod_cmd_export_t(char* name, int flags);
83-
acmd_export_t* find_mod_acmd_export_t(char* name);
81+
const cmd_export_t* find_core_cmd_export_t(const char* name, int flags);
82+
const cmd_export_t* find_mod_cmd_export_t(const char* name, int flags);
83+
const acmd_export_t* find_mod_acmd_export_t(const char* name);
8484

8585
#endif /* _CORE_CMDS_H_ */

core_cmds.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static int w_script_trace(struct sip_msg *msg, int *log_level,
122122
pv_elem_t *fmt_string, void *info_str);
123123
static int w_is_myself(struct sip_msg *msg, str *host, int *port);
124124

125-
static cmd_export_t core_cmds[]={
125+
static const cmd_export_t core_cmds[]={
126126
{"forward", (cmd_function)w_forward, {
127127
{CMD_PARAM_STR|CMD_PARAM_OPT|CMD_PARAM_FIX_NULL,
128128
fixup_forward_dest, fixup_free_destination}, {0,0,0}},
@@ -345,9 +345,9 @@ static cmd_export_t core_cmds[]={
345345
};
346346

347347

348-
cmd_export_t* find_core_cmd_export_t(char* name, int flags)
348+
const cmd_export_t* find_core_cmd_export_t(const char* name, int flags)
349349
{
350-
cmd_export_t* cmd;
350+
const cmd_export_t* cmd;
351351

352352
for(cmd=core_cmds; cmd && cmd->name; cmd++){
353353
if((strcmp(name, cmd->name)==0)&&((cmd->flags & flags) == flags)){

lib/reg/pn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ int pn_cfg_validate(void)
224224
}
225225

226226

227-
struct module_dependency *pn_get_deps(param_export_t *param)
227+
struct module_dependency *pn_get_deps(const param_export_t *param)
228228
{
229229
int pn_is_on = *(int *)param->param_pointer;
230230

lib/reg/pn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ extern char *_pn_providers;
9898

9999

100100
/* module dependencies */
101-
struct module_dependency *pn_get_deps(param_export_t *param);
101+
struct module_dependency *pn_get_deps(const param_export_t *param);
102102

103103
#define pn_modparam_deps \
104104
{"pn_enable", pn_get_deps}

mi/item.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef flush_fn mi_flush_f;
5353

5454
typedef struct mi_params_ {
5555
mi_item_t *item;
56-
char **list;
56+
char * const *list;
5757
} mi_params_t;
5858

5959
/* The functions below can be used to build a MI Response

mi/mi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static inline struct mi_cmd* lookup_mi_cmd_id(int id,char *name, int len)
8585
}
8686

8787

88-
int register_mi_mod( char *mod_name, mi_export_t *mis)
88+
int register_mi_mod(const char *mod_name, const mi_export_t *mis)
8989
{
9090
int ret;
9191
int i;
@@ -123,7 +123,7 @@ int init_mi_child(void)
123123

124124

125125
int register_mi_cmd(char *name, char *help, unsigned int flags,
126-
mi_child_init_f in, mi_recipe_t *recipes, char* mod_name)
126+
mi_child_init_f in, const mi_recipe_t *recipes, const char* mod_name)
127127
{
128128
struct mi_cmd *cmds;
129129
int id;
@@ -253,7 +253,7 @@ char *mi_get_req_method(mi_request_t *req)
253253
return req->method->valuestring;
254254
}
255255

256-
static int match_named_params(mi_recipe_t *recipe, mi_item_t *req_params)
256+
static int match_named_params(const mi_recipe_t *recipe, mi_item_t *req_params)
257257
{
258258
mi_item_t *param;
259259
int i;
@@ -270,7 +270,7 @@ static int match_named_params(mi_recipe_t *recipe, mi_item_t *req_params)
270270
return 1;
271271
}
272272

273-
static int match_no_params(mi_recipe_t *recipe, mi_item_t *req_params)
273+
static int match_no_params(const mi_recipe_t *recipe, mi_item_t *req_params)
274274
{
275275
mi_item_t *param;
276276
int i, j;
@@ -282,10 +282,10 @@ static int match_no_params(mi_recipe_t *recipe, mi_item_t *req_params)
282282
return i == j;
283283
}
284284

285-
static mi_recipe_t *get_cmd_recipe(mi_recipe_t *recipes, mi_item_t *req_params,
285+
static const mi_recipe_t *get_cmd_recipe(const mi_recipe_t *recipes, mi_item_t *req_params,
286286
int pos_params, int *params_err)
287287
{
288-
mi_recipe_t *match = NULL;
288+
const mi_recipe_t *match = NULL;
289289
int i;
290290

291291
for (i = 0; recipes[i].cmd; i++) {
@@ -338,7 +338,7 @@ mi_response_t *handle_mi_request(mi_request_t *req, struct mi_cmd *cmd,
338338
struct mi_handler *async_hdl)
339339
{
340340
mi_response_t *resp;
341-
mi_recipe_t *cmd_recipe;
341+
const mi_recipe_t *cmd_recipe;
342342
mi_params_t cmd_params;
343343
int params_err = -1;
344344
int pos_params;

mi/mi.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ typedef struct mi_recipe_ {
8484

8585
struct mi_cmd {
8686
int id;
87-
str module;
87+
str_const module;
8888
str name;
8989
str help;
9090
mi_child_init_f *init_f;
9191
unsigned int flags;
92-
mi_recipe_t *recipes;
92+
const mi_recipe_t *recipes;
9393

9494
volatile unsigned char* trace_mask;
9595
};
@@ -115,9 +115,9 @@ typedef struct mi_request_ {
115115

116116

117117
int register_mi_cmd(char *name, char *help, unsigned int flags,
118-
mi_child_init_f in, mi_recipe_t *recipes, char* mod_name);
118+
mi_child_init_f in, const mi_recipe_t *recipes, const char* mod_name);
119119

120-
int register_mi_mod(char *mod_name, mi_export_t *mis);
120+
int register_mi_mod(const char *mod_name, const mi_export_t *mis);
121121

122122
int init_mi_child();
123123

mod_fix.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ int check_cmd(struct cmd_param *params, action_elem_t *elems)
145145
return 0;
146146
}
147147

148-
int fix_cmd(struct cmd_param *params, action_elem_t *elems)
148+
int fix_cmd(const struct cmd_param *params, action_elem_t *elems)
149149
{
150150
int i;
151-
struct cmd_param *param;
151+
const struct cmd_param *param;
152152
gparam_p gp = NULL;
153153
int ret;
154154
pv_elem_t *pve;
@@ -330,11 +330,11 @@ int fix_cmd(struct cmd_param *params, action_elem_t *elems)
330330
return ret;
331331
}
332332

333-
int get_cmd_fixups(struct sip_msg* msg, struct cmd_param *params,
333+
int get_cmd_fixups(struct sip_msg* msg, const struct cmd_param *params,
334334
action_elem_t *elems, void **cmdp, pv_value_t *tmp_vals)
335335
{
336336
int i;
337-
struct cmd_param *param;
337+
const struct cmd_param *param;
338338
gparam_p gp;
339339
regex_t *re = NULL;
340340
int ret;
@@ -487,10 +487,10 @@ int get_cmd_fixups(struct sip_msg* msg, struct cmd_param *params,
487487
return 0;
488488
}
489489

490-
int free_cmd_fixups(struct cmd_param *params, action_elem_t *elems, void **cmdp)
490+
int free_cmd_fixups(const struct cmd_param *params, action_elem_t *elems, void **cmdp)
491491
{
492492
int i;
493-
struct cmd_param *param;
493+
const struct cmd_param *param;
494494
gparam_p gp;
495495

496496
for (param=params, i=1; param->flags; param++, i++) {

mod_fix.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ typedef struct _gparam
4646
struct cmd_param;
4747

4848
int check_cmd(struct cmd_param *params, action_elem_t *elems);
49-
int fix_cmd(struct cmd_param *params, action_elem_t *elems);
50-
int get_cmd_fixups(struct sip_msg* msg, struct cmd_param *params,
49+
int fix_cmd(const struct cmd_param *params, action_elem_t *elems);
50+
int get_cmd_fixups(struct sip_msg* msg, const struct cmd_param *params,
5151
action_elem_t *elems, void **cmdp, pv_value_t *tmp_val);
52-
int free_cmd_fixups(struct cmd_param *params, action_elem_t *elems, void **cmdp);
52+
int free_cmd_fixups(const struct cmd_param *params, action_elem_t *elems, void **cmdp);
5353

5454
static inline int fixup_free_pkg(void **param)
5555
{

modparam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
4242
{
4343
struct sr_module* t;
44-
param_export_t* param;
44+
const param_export_t* param;
4545
regex_t preg;
4646
int mod_found, param_found, len;
4747
char* reg;

modules/acc/acc_mod.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static param_export_t params[] = {
230230
{0,0,0}
231231
};
232232

233-
static module_dependency_t *get_deps_aaa_url(param_export_t *param)
233+
static module_dependency_t *get_deps_aaa_url(const param_export_t *param)
234234
{
235235
char *aaa_url = *(char **)param->param_pointer;
236236

@@ -240,7 +240,7 @@ static module_dependency_t *get_deps_aaa_url(param_export_t *param)
240240
return alloc_module_dep(MOD_TYPE_AAA, NULL, DEP_WARN);
241241
}
242242

243-
static module_dependency_t *get_deps_detect_dir(param_export_t *param)
243+
static module_dependency_t *get_deps_detect_dir(const param_export_t *param)
244244
{
245245
if (*(int *)param->param_pointer == 0)
246246
return NULL;

modules/auth_aaa/authaaa_mod.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static param_export_t params[] = {
9999
* functions are used from the script - we do a small trick here and
100100
* hook on the 'aaa_url' mandatory param to run the check, even if the
101101
* param value is not involved in the test */
102-
static module_dependency_t *get_deps_aaa_url(param_export_t *param)
102+
static module_dependency_t *get_deps_aaa_url(const param_export_t *param)
103103
{
104104
if (is_script_func_used("aaa_www_authorize", -1) ||
105105
is_script_func_used("aaa_proxy_authorize", -1) )

modules/cachedb_redis/cachedb_redis.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ static param_export_t params[]={
6161
{0,0,0}
6262
};
6363

64-
static module_dependency_t *get_deps_use_tls(param_export_t *param)
64+
static module_dependency_t *get_deps_use_tls(const param_export_t *param)
6565
{
6666
if (*(int *)param->param_pointer == 0)
6767
return NULL;
6868

6969
return alloc_module_dep(MOD_TYPE_DEFAULT, "tls_mgm", DEP_ABORT);
7070
}
7171

72-
static module_dependency_t *get_deps_use_tls_openssl(param_export_t *param)
72+
static module_dependency_t *get_deps_use_tls_openssl(const param_export_t *param)
7373
{
7474
if (*(int *)param->param_pointer == 0)
7575
return NULL;

modules/clusterer/api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static inline int load_clusterer_api(struct clusterer_binds *binds) {
317317
}
318318

319319
/* function used to add dependencies to clusterer module */
320-
static inline module_dependency_t *get_deps_clusterer(param_export_t *param)
320+
static inline module_dependency_t *get_deps_clusterer(const param_export_t *param)
321321
{
322322
int cluster_id = *(int *)param->param_pointer;
323323

modules/clusterer/clusterer_mod.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static pv_export_t mod_vars[] = {
236236
};
237237

238238

239-
static module_dependency_t *get_deps_db_mode(param_export_t *param)
239+
static module_dependency_t *get_deps_db_mode(const param_export_t *param)
240240
{
241241
int db_mode = *(int *)param->param_pointer;
242242

modules/cpl_c/cpl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static mi_export_t mi_cmds[] = {
172172
{EMPTY_MI_EXPORT}
173173
};
174174

175-
static module_dependency_t *get_deps_lookup_domain(param_export_t *param)
175+
static module_dependency_t *get_deps_lookup_domain(const param_export_t *param)
176176
{
177177
char *domain = *(char **)param->param_pointer;
178178
if (!domain || strlen(domain) == 0)

modules/db_mysql/db_mysql.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static param_export_t params[] = {
8080
{0, 0, 0}
8181
};
8282

83-
static module_dependency_t *get_deps_use_tls(param_export_t *param)
83+
static module_dependency_t *get_deps_use_tls(const param_export_t *param)
8484
{
8585
if (*(int *)param->param_pointer == 0)
8686
return NULL;

modules/db_postgres/db_postgres.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static param_export_t params[] = {
6767
{0, 0, 0}
6868
};
6969

70-
static module_dependency_t *get_deps_use_tls(param_export_t *param)
70+
static module_dependency_t *get_deps_use_tls(const param_export_t *param)
7171
{
7272
if (*(int *)param->param_pointer == 0)
7373
return NULL;

modules/dialog/dialog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static pv_export_t mod_items[] = {
457457
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
458458
};
459459

460-
static module_dependency_t *get_deps_db_mode(param_export_t *param)
460+
static module_dependency_t *get_deps_db_mode(const param_export_t *param)
461461
{
462462
int db_mode = *(int *)param->param_pointer;
463463

modules/dispatcher/dispatcher.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,15 @@ static param_export_t params[]={
318318
{0,0,0}
319319
};
320320

321-
static module_dependency_t *get_deps_ds_ping_interval(param_export_t *param)
321+
static module_dependency_t *get_deps_ds_ping_interval(const param_export_t *param)
322322
{
323323
if (*(int *)param->param_pointer <= 0)
324324
return NULL;
325325

326326
return alloc_module_dep(MOD_TYPE_DEFAULT, "tm", DEP_ABORT);
327327
}
328328

329-
static module_dependency_t *get_deps_fetch_fs_load(param_export_t *param)
329+
static module_dependency_t *get_deps_fetch_fs_load(const param_export_t *param)
330330
{
331331
if (*(int *)param->param_pointer <= 0)
332332
return NULL;

modules/drouting/drouting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ static mi_export_t mi_cmds[] = {
576576
{EMPTY_MI_EXPORT}
577577
};
578578

579-
static module_dependency_t *get_deps_probing_interval(param_export_t *param)
579+
static module_dependency_t *get_deps_probing_interval(const param_export_t *param)
580580
{
581581
if (*(int *)param->param_pointer <= 0)
582582
return NULL;

modules/event_rabbitmq/event_rabbitmq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static param_export_t mod_params[] = {
7474
{0,0,0}
7575
};
7676

77-
static module_dependency_t *get_deps_use_tls(param_export_t *param)
77+
static module_dependency_t *get_deps_use_tls(const param_export_t *param)
7878
{
7979
if (*(int *)param->param_pointer == 0)
8080
return NULL;

0 commit comments

Comments
 (0)