Skip to content

Commit

Permalink
Make appropriate fields of the module_exports const.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Feb 14, 2023
1 parent 6e03e9f commit e470daa
Show file tree
Hide file tree
Showing 57 changed files with 151 additions and 148 deletions.
4 changes: 2 additions & 2 deletions action.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ int do_action(struct action* a, struct sip_msg* msg)
pv_value_t val;
struct timeval start;
int end_time;
cmd_export_t *cmd = NULL;
const cmd_export_t *cmd = NULL;
acmd_export_t *acmd;
void* cmdp[MAX_CMD_PARAMS];
pv_value_t tmp_vals[MAX_CMD_PARAMS];
Expand Down Expand Up @@ -1026,7 +1026,7 @@ int do_action(struct action* a, struct sip_msg* msg)
break;
case CMD_T:
if (a->elem[0].type != CMD_ST ||
((cmd = (cmd_export_t*)a->elem[0].u.data) == NULL)) {
((cmd = (const cmd_export_t*)a->elem[0].u.data) == NULL)) {
LM_ALERT("BUG in module call\n");
break;
}
Expand Down
8 changes: 4 additions & 4 deletions cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

#include "cmds.h"

cmd_export_t* find_cmd_export_t(char* name, int flags)
const cmd_export_t* find_cmd_export_t(const char* name, int flags)
{
cmd_export_t* cmd;
const cmd_export_t* cmd;

cmd = find_core_cmd_export_t(name, flags);
if (!cmd)
Expand All @@ -40,9 +40,9 @@ cmd_export_t* find_cmd_export_t(char* name, int flags)
* -2 - too many parameters
* -3 - mandatory parameter omitted
*/
int check_cmd_call_params(cmd_export_t *cmd, action_elem_t *elems, int no_params)
int check_cmd_call_params(const cmd_export_t *cmd, action_elem_t *elems, int no_params)
{
struct cmd_param *param;
const struct cmd_param *param;
int n=0, m=0, i;

for (param=cmd->params; param->flags; param++, n++)
Expand Down
10 changes: 5 additions & 5 deletions cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ struct acmd_export_ {
typedef struct cmd_export_ cmd_export_t;
typedef struct acmd_export_ acmd_export_t;

cmd_export_t* find_cmd_export_t(char* name, int flags);
int check_cmd_call_params(cmd_export_t *cmd, action_elem_t *elems, int no_params);
const cmd_export_t* find_cmd_export_t(const char* name, int flags);
int check_cmd_call_params(const cmd_export_t *cmd, action_elem_t *elems, int no_params);
int check_acmd_call_params(acmd_export_t *acmd, action_elem_t *elems, int no_params);

cmd_export_t* find_core_cmd_export_t(char* name, int flags);
cmd_export_t* find_mod_cmd_export_t(char* name, int flags);
acmd_export_t* find_mod_acmd_export_t(char* name);
const cmd_export_t* find_core_cmd_export_t(const char* name, int flags);
const cmd_export_t* find_mod_cmd_export_t(const char* name, int flags);
const acmd_export_t* find_mod_acmd_export_t(const char* name);

#endif /* _CORE_CMDS_H_ */
6 changes: 3 additions & 3 deletions core_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static int w_script_trace(struct sip_msg *msg, int *log_level,
pv_elem_t *fmt_string, void *info_str);
static int w_is_myself(struct sip_msg *msg, str *host, int *port);

static cmd_export_t core_cmds[]={
static const cmd_export_t core_cmds[]={
{"forward", (cmd_function)w_forward, {
{CMD_PARAM_STR|CMD_PARAM_OPT|CMD_PARAM_FIX_NULL,
fixup_forward_dest, fixup_free_destination}, {0,0,0}},
Expand Down Expand Up @@ -345,9 +345,9 @@ static cmd_export_t core_cmds[]={
};


cmd_export_t* find_core_cmd_export_t(char* name, int flags)
const cmd_export_t* find_core_cmd_export_t(const char* name, int flags)
{
cmd_export_t* cmd;
const cmd_export_t* cmd;

for(cmd=core_cmds; cmd && cmd->name; cmd++){
if((strcmp(name, cmd->name)==0)&&((cmd->flags & flags) == flags)){
Expand Down
2 changes: 1 addition & 1 deletion lib/reg/pn.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ int pn_cfg_validate(void)
}


struct module_dependency *pn_get_deps(param_export_t *param)
struct module_dependency *pn_get_deps(const param_export_t *param)
{
int pn_is_on = *(int *)param->param_pointer;

Expand Down
2 changes: 1 addition & 1 deletion lib/reg/pn.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ extern char *_pn_providers;


/* module dependencies */
struct module_dependency *pn_get_deps(param_export_t *param);
struct module_dependency *pn_get_deps(const param_export_t *param);

#define pn_modparam_deps \
{"pn_enable", pn_get_deps}
Expand Down
2 changes: 1 addition & 1 deletion mi/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef flush_fn mi_flush_f;

typedef struct mi_params_ {
mi_item_t *item;
char **list;
char * const *list;
} mi_params_t;

/* The functions below can be used to build a MI Response
Expand Down
14 changes: 7 additions & 7 deletions mi/mi.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static inline struct mi_cmd* lookup_mi_cmd_id(int id,char *name, int len)
}


int register_mi_mod( char *mod_name, mi_export_t *mis)
int register_mi_mod(const char *mod_name, const mi_export_t *mis)
{
int ret;
int i;
Expand Down Expand Up @@ -123,7 +123,7 @@ int init_mi_child(void)


int register_mi_cmd(char *name, char *help, unsigned int flags,
mi_child_init_f in, mi_recipe_t *recipes, char* mod_name)
mi_child_init_f in, const mi_recipe_t *recipes, const char* mod_name)
{
struct mi_cmd *cmds;
int id;
Expand Down Expand Up @@ -253,7 +253,7 @@ char *mi_get_req_method(mi_request_t *req)
return req->method->valuestring;
}

static int match_named_params(mi_recipe_t *recipe, mi_item_t *req_params)
static int match_named_params(const mi_recipe_t *recipe, mi_item_t *req_params)
{
mi_item_t *param;
int i;
Expand All @@ -270,7 +270,7 @@ static int match_named_params(mi_recipe_t *recipe, mi_item_t *req_params)
return 1;
}

static int match_no_params(mi_recipe_t *recipe, mi_item_t *req_params)
static int match_no_params(const mi_recipe_t *recipe, mi_item_t *req_params)
{
mi_item_t *param;
int i, j;
Expand All @@ -282,10 +282,10 @@ static int match_no_params(mi_recipe_t *recipe, mi_item_t *req_params)
return i == j;
}

static mi_recipe_t *get_cmd_recipe(mi_recipe_t *recipes, mi_item_t *req_params,
static const mi_recipe_t *get_cmd_recipe(const mi_recipe_t *recipes, mi_item_t *req_params,
int pos_params, int *params_err)
{
mi_recipe_t *match = NULL;
const mi_recipe_t *match = NULL;
int i;

for (i = 0; recipes[i].cmd; i++) {
Expand Down Expand Up @@ -338,7 +338,7 @@ mi_response_t *handle_mi_request(mi_request_t *req, struct mi_cmd *cmd,
struct mi_handler *async_hdl)
{
mi_response_t *resp;
mi_recipe_t *cmd_recipe;
const mi_recipe_t *cmd_recipe;
mi_params_t cmd_params;
int params_err = -1;
int pos_params;
Expand Down
8 changes: 4 additions & 4 deletions mi/mi.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ typedef struct mi_recipe_ {

struct mi_cmd {
int id;
str module;
str_const module;
str name;
str help;
mi_child_init_f *init_f;
unsigned int flags;
mi_recipe_t *recipes;
const mi_recipe_t *recipes;

volatile unsigned char* trace_mask;
};
Expand All @@ -115,9 +115,9 @@ typedef struct mi_request_ {


int register_mi_cmd(char *name, char *help, unsigned int flags,
mi_child_init_f in, mi_recipe_t *recipes, char* mod_name);
mi_child_init_f in, const mi_recipe_t *recipes, const char* mod_name);

int register_mi_mod(char *mod_name, mi_export_t *mis);
int register_mi_mod(const char *mod_name, const mi_export_t *mis);

int init_mi_child();

Expand Down
12 changes: 6 additions & 6 deletions mod_fix.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ int check_cmd(struct cmd_param *params, action_elem_t *elems)
return 0;
}

int fix_cmd(struct cmd_param *params, action_elem_t *elems)
int fix_cmd(const struct cmd_param *params, action_elem_t *elems)
{
int i;
struct cmd_param *param;
const struct cmd_param *param;
gparam_p gp = NULL;
int ret;
pv_elem_t *pve;
Expand Down Expand Up @@ -330,11 +330,11 @@ int fix_cmd(struct cmd_param *params, action_elem_t *elems)
return ret;
}

int get_cmd_fixups(struct sip_msg* msg, struct cmd_param *params,
int get_cmd_fixups(struct sip_msg* msg, const struct cmd_param *params,
action_elem_t *elems, void **cmdp, pv_value_t *tmp_vals)
{
int i;
struct cmd_param *param;
const struct cmd_param *param;
gparam_p gp;
regex_t *re = NULL;
int ret;
Expand Down Expand Up @@ -487,10 +487,10 @@ int get_cmd_fixups(struct sip_msg* msg, struct cmd_param *params,
return 0;
}

int free_cmd_fixups(struct cmd_param *params, action_elem_t *elems, void **cmdp)
int free_cmd_fixups(const struct cmd_param *params, action_elem_t *elems, void **cmdp)
{
int i;
struct cmd_param *param;
const struct cmd_param *param;
gparam_p gp;

for (param=params, i=1; param->flags; param++, i++) {
Expand Down
6 changes: 3 additions & 3 deletions mod_fix.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ typedef struct _gparam
struct cmd_param;

int check_cmd(struct cmd_param *params, action_elem_t *elems);
int fix_cmd(struct cmd_param *params, action_elem_t *elems);
int get_cmd_fixups(struct sip_msg* msg, struct cmd_param *params,
int fix_cmd(const struct cmd_param *params, action_elem_t *elems);
int get_cmd_fixups(struct sip_msg* msg, const struct cmd_param *params,
action_elem_t *elems, void **cmdp, pv_value_t *tmp_val);
int free_cmd_fixups(struct cmd_param *params, action_elem_t *elems, void **cmdp);
int free_cmd_fixups(const struct cmd_param *params, action_elem_t *elems, void **cmdp);

static inline int fixup_free_pkg(void **param)
{
Expand Down
2 changes: 1 addition & 1 deletion modparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
{
struct sr_module* t;
param_export_t* param;
const param_export_t* param;
regex_t preg;
int mod_found, param_found, len;
char* reg;
Expand Down
4 changes: 2 additions & 2 deletions modules/acc/acc_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static param_export_t params[] = {
{0,0,0}
};

static module_dependency_t *get_deps_aaa_url(param_export_t *param)
static module_dependency_t *get_deps_aaa_url(const param_export_t *param)
{
char *aaa_url = *(char **)param->param_pointer;

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

static module_dependency_t *get_deps_detect_dir(param_export_t *param)
static module_dependency_t *get_deps_detect_dir(const param_export_t *param)
{
if (*(int *)param->param_pointer == 0)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/auth_aaa/authaaa_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static param_export_t params[] = {
* functions are used from the script - we do a small trick here and
* hook on the 'aaa_url' mandatory param to run the check, even if the
* param value is not involved in the test */
static module_dependency_t *get_deps_aaa_url(param_export_t *param)
static module_dependency_t *get_deps_aaa_url(const param_export_t *param)
{
if (is_script_func_used("aaa_www_authorize", -1) ||
is_script_func_used("aaa_proxy_authorize", -1) )
Expand Down
4 changes: 2 additions & 2 deletions modules/cachedb_redis/cachedb_redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ static param_export_t params[]={
{0,0,0}
};

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

return alloc_module_dep(MOD_TYPE_DEFAULT, "tls_mgm", DEP_ABORT);
}

static module_dependency_t *get_deps_use_tls_openssl(param_export_t *param)
static module_dependency_t *get_deps_use_tls_openssl(const param_export_t *param)
{
if (*(int *)param->param_pointer == 0)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/clusterer/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static inline int load_clusterer_api(struct clusterer_binds *binds) {
}

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

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 @@ -236,7 +236,7 @@ static pv_export_t mod_vars[] = {
};


static module_dependency_t *get_deps_db_mode(param_export_t *param)
static module_dependency_t *get_deps_db_mode(const param_export_t *param)
{
int db_mode = *(int *)param->param_pointer;

Expand Down
2 changes: 1 addition & 1 deletion modules/cpl_c/cpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static mi_export_t mi_cmds[] = {
{EMPTY_MI_EXPORT}
};

static module_dependency_t *get_deps_lookup_domain(param_export_t *param)
static module_dependency_t *get_deps_lookup_domain(const param_export_t *param)
{
char *domain = *(char **)param->param_pointer;
if (!domain || strlen(domain) == 0)
Expand Down
2 changes: 1 addition & 1 deletion modules/db_mysql/db_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static param_export_t params[] = {
{0, 0, 0}
};

static module_dependency_t *get_deps_use_tls(param_export_t *param)
static module_dependency_t *get_deps_use_tls(const param_export_t *param)
{
if (*(int *)param->param_pointer == 0)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/db_postgres/db_postgres.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static param_export_t params[] = {
{0, 0, 0}
};

static module_dependency_t *get_deps_use_tls(param_export_t *param)
static module_dependency_t *get_deps_use_tls(const param_export_t *param)
{
if (*(int *)param->param_pointer == 0)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/dialog/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ static pv_export_t mod_items[] = {
{ {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
};

static module_dependency_t *get_deps_db_mode(param_export_t *param)
static module_dependency_t *get_deps_db_mode(const param_export_t *param)
{
int db_mode = *(int *)param->param_pointer;

Expand Down
4 changes: 2 additions & 2 deletions modules/dispatcher/dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,15 @@ static param_export_t params[]={
{0,0,0}
};

static module_dependency_t *get_deps_ds_ping_interval(param_export_t *param)
static module_dependency_t *get_deps_ds_ping_interval(const param_export_t *param)
{
if (*(int *)param->param_pointer <= 0)
return NULL;

return alloc_module_dep(MOD_TYPE_DEFAULT, "tm", DEP_ABORT);
}

static module_dependency_t *get_deps_fetch_fs_load(param_export_t *param)
static module_dependency_t *get_deps_fetch_fs_load(const param_export_t *param)
{
if (*(int *)param->param_pointer <= 0)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/drouting/drouting.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ static mi_export_t mi_cmds[] = {
{EMPTY_MI_EXPORT}
};

static module_dependency_t *get_deps_probing_interval(param_export_t *param)
static module_dependency_t *get_deps_probing_interval(const param_export_t *param)
{
if (*(int *)param->param_pointer <= 0)
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion modules/event_rabbitmq/event_rabbitmq.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static param_export_t mod_params[] = {
{0,0,0}
};

static module_dependency_t *get_deps_use_tls(param_export_t *param)
static module_dependency_t *get_deps_use_tls(const param_export_t *param)
{
if (*(int *)param->param_pointer == 0)
return NULL;
Expand Down
Loading

0 comments on commit e470daa

Please sign in to comment.