From f52dd528c488c9b0c6f55bd4720f9a53868d2f7e Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 17 May 2023 16:36:05 +0200 Subject: [PATCH] drouting: clang-format for coherent indentation and coding style --- src/modules/drouting/dr_load.c | 2 +- src/modules/drouting/dr_time.c | 37 ++++++++++++++------------------- src/modules/drouting/drouting.c | 22 +++++++++++--------- src/modules/drouting/routing.c | 15 ++++++++----- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/modules/drouting/dr_load.c b/src/modules/drouting/dr_load.c index 754e9b285a5..8716ddb1bd7 100644 --- a/src/modules/drouting/dr_load.c +++ b/src/modules/drouting/dr_load.c @@ -87,7 +87,7 @@ static struct dr_gwl_tmp *dr_gw_lists = NULL; #define check_val(_val, _type, _not_null, _is_empty_str) \ do { \ if((_val)->type != _type) { \ - LM_ERR("bad column type\n"); \ + LM_ERR("bad column type\n"); \ goto error; \ } \ if(_not_null && (_val)->nul) { \ diff --git a/src/modules/drouting/dr_time.c b/src/modules/drouting/dr_time.c index 535dbd0b1bd..93ad4871ca8 100644 --- a/src/modules/drouting/dr_time.c +++ b/src/modules/drouting/dr_time.c @@ -73,8 +73,7 @@ dr_ac_tm_p dr_ac_tm_new(void) { dr_ac_tm_p _atp = NULL; _atp = (dr_ac_tm_p)shm_malloc(sizeof(dr_ac_tm_t)); - if(!_atp) - { + if(!_atp) { SHM_MEM_ERROR; return NULL; } @@ -87,14 +86,14 @@ int dr_ac_tm_fill(dr_ac_tm_p _atp, struct tm *_tm) { if(!_atp || !_tm) return -1; - _atp->t.tm_sec = _tm->tm_sec; /* seconds */ - _atp->t.tm_min = _tm->tm_min; /* minutes */ - _atp->t.tm_hour = _tm->tm_hour; /* hours */ - _atp->t.tm_mday = _tm->tm_mday; /* day of the month */ - _atp->t.tm_mon = _tm->tm_mon; /* month */ - _atp->t.tm_year = _tm->tm_year; /* year */ - _atp->t.tm_wday = _tm->tm_wday; /* day of the week */ - _atp->t.tm_yday = _tm->tm_yday; /* day in the year */ + _atp->t.tm_sec = _tm->tm_sec; /* seconds */ + _atp->t.tm_min = _tm->tm_min; /* minutes */ + _atp->t.tm_hour = _tm->tm_hour; /* hours */ + _atp->t.tm_mday = _tm->tm_mday; /* day of the month */ + _atp->t.tm_mon = _tm->tm_mon; /* month */ + _atp->t.tm_year = _tm->tm_year; /* year */ + _atp->t.tm_wday = _tm->tm_wday; /* day of the week */ + _atp->t.tm_yday = _tm->tm_yday; /* day in the year */ _atp->t.tm_isdst = _tm->tm_isdst; /* daylight saving time */ _atp->mweek = dr_ac_get_mweek(_tm); @@ -190,10 +189,9 @@ dr_ac_maxval_p dr_ac_get_maxval(dr_ac_tm_p _atp, int mode) if(!_atp) return NULL; - if(mode==1) { + if(mode == 1) { _amp = (dr_ac_maxval_p)shm_malloc(sizeof(dr_ac_maxval_t)); - if(!_amp) - { + if(!_amp) { SHM_MEM_ERROR; return NULL; } @@ -256,8 +254,8 @@ dr_ac_maxval_p dr_ac_get_maxval(dr_ac_tm_p _atp, int mode) + 1; #endif - if(mode==1) { - if(_atp->mv!=NULL) { + if(mode == 1) { + if(_atp->mv != NULL) { shm_free(_atp->mv); } @@ -275,8 +273,7 @@ dr_tr_byxxx_p dr_tr_byxxx_new(void) { dr_tr_byxxx_p _bxp = NULL; _bxp = (dr_tr_byxxx_p)shm_malloc(sizeof(dr_tr_byxxx_t)); - if(!_bxp) - { + if(!_bxp) { SHM_MEM_ERROR; return NULL; } @@ -290,8 +287,7 @@ int dr_tr_byxxx_init(dr_tr_byxxx_p _bxp, int _nr) return -1; _bxp->nr = _nr; _bxp->xxx = (int *)shm_malloc(_nr * sizeof(int)); - if(!_bxp->xxx) - { + if(!_bxp->xxx) { SHM_MEM_ERROR; return -1; } @@ -325,8 +321,7 @@ dr_tmrec_p dr_tmrec_new(void) { dr_tmrec_p _trp = NULL; _trp = (dr_tmrec_p)shm_malloc(sizeof(dr_tmrec_t)); - if(!_trp) - { + if(!_trp) { SHM_MEM_ERROR; return NULL; } diff --git a/src/modules/drouting/drouting.c b/src/modules/drouting/drouting.c index cdf75cac985..bdc4b1c694f 100644 --- a/src/modules/drouting/drouting.c +++ b/src/modules/drouting/drouting.c @@ -52,7 +52,7 @@ /*** DB relatede stuff ***/ /* parameters */ -static str db_url = str_init(DEFAULT_RODB_URL); +static str db_url = str_init(DEFAULT_RODB_URL); static str drg_table = str_init("dr_groups"); static str drd_table = str_init("dr_gateways"); static str drr_table = str_init("dr_rules"); @@ -364,8 +364,10 @@ static int dr_init(void) reload_flag = (int *)shm_malloc(sizeof(int)); if(!data_refcnt || !reload_flag) { SHM_MEM_ERROR; - if(data_refcnt) shm_free(data_refcnt); - if(reload_flag) shm_free(reload_flag); + if(data_refcnt) + shm_free(data_refcnt); + if(reload_flag) + shm_free(reload_flag); goto error; } *data_refcnt = 0; @@ -644,7 +646,8 @@ static int ki_do_routing_furi(sip_msg_t *msg) grp_id = get_group_id(&uri); if(grp_id < 0) { LM_ERR("failed to get group id\n"); - return -1;; + return -1; + ; } return do_routing(msg, grp_id); @@ -658,7 +661,7 @@ static int do_routing_0(struct sip_msg *msg, char *str1, char *str2) static int do_routing_1(struct sip_msg *msg, char *str1, char *str2) { int grp_id; - if(fixup_get_ivalue(msg, (gparam_t*)str1, &grp_id)<0) { + if(fixup_get_ivalue(msg, (gparam_t *)str1, &grp_id) < 0) { LM_ERR("failed to get group id parameter\n"); return -1; } @@ -990,7 +993,6 @@ static int do_routing(struct sip_msg *msg, int grp_id) } - static int strip_username(struct sip_msg *msg, int strip) { struct action act; @@ -1054,7 +1056,7 @@ static int is_from_gw_1(struct sip_msg *msg, char *str1, char *str2) { int type; - if(fixup_get_ivalue(msg, (gparam_t*)str1, &type)<0) { + if(fixup_get_ivalue(msg, (gparam_t *)str1, &type) < 0) { LM_ERR("failed to get parameter value\n"); return -1; } @@ -1088,11 +1090,11 @@ static int is_from_gw_2(struct sip_msg *msg, char *str1, char *str2) int type; int flags; - if(fixup_get_ivalue(msg, (gparam_t*)str1, &type)<0) { + if(fixup_get_ivalue(msg, (gparam_t *)str1, &type) < 0) { LM_ERR("failed to get type parameter value\n"); return -1; } - if(fixup_get_ivalue(msg, (gparam_t*)str2, &flags)<0) { + if(fixup_get_ivalue(msg, (gparam_t *)str2, &flags) < 0) { LM_ERR("failed to get flags parameter value\n"); return -1; } @@ -1132,7 +1134,7 @@ static int ki_goes_to_gw_type(struct sip_msg *msg, int type) static int goes_to_gw_1(struct sip_msg *msg, char *_type, char *_f2) { int type; - if(fixup_get_ivalue(msg, (gparam_t*)_type, &type)<0) { + if(fixup_get_ivalue(msg, (gparam_t *)_type, &type) < 0) { LM_ERR("failed to get parameter value\n"); return -1; } diff --git a/src/modules/drouting/routing.c b/src/modules/drouting/routing.c index 4d162b9cac4..e9a821bcd1e 100644 --- a/src/modules/drouting/routing.c +++ b/src/modules/drouting/routing.c @@ -112,7 +112,8 @@ rt_info_t *build_rt_info(int priority, dr_tmrec_t *trec, n++; /* reallocate the array which keeps the parsed indexes */ if(n >= idx_size) { - if(NULL == ((t_idx) = (int *)shm_malloc( + if(NULL + == ((t_idx) = (int *)shm_malloc( (idx_size * 2 * 2) * sizeof(int)))) { LM_ERR("out of shm\n"); goto err_exit; @@ -135,7 +136,8 @@ rt_info_t *build_rt_info(int priority, dr_tmrec_t *trec, } /* create the pgwl */ rt->pgwa_len = n; - if(NULL == (rt->pgwl = (pgw_list_t *)shm_malloc( + if(NULL + == (rt->pgwl = (pgw_list_t *)shm_malloc( rt->pgwa_len * sizeof(pgw_list_t)))) { SHM_MEM_ERROR; goto err_exit; @@ -186,7 +188,8 @@ int add_rt_info(ptree_node_t *pn, rt_info_t *r, unsigned int rgid) if(NULL == pn->rg) { /* allocate the routing groups array */ pn->rg_len = RG_INIT_LEN; - if(NULL == (pn->rg = (rg_entry_t *)shm_malloc( + if(NULL + == (pn->rg = (rg_entry_t *)shm_malloc( pn->rg_len * sizeof(rg_entry_t)))) { /* recover the old pointer to be able to shm_free mem */ SHM_MEM_ERROR; @@ -201,7 +204,8 @@ int add_rt_info(ptree_node_t *pn, rt_info_t *r, unsigned int rgid) if((i == pn->rg_len - 1) && (pn->rg[i].rgid != rgid)) { /* realloc & copy the old rg */ trg = pn->rg; - if(NULL == (pn->rg = (rg_entry_t *)shm_malloc( + if(NULL + == (pn->rg = (rg_entry_t *)shm_malloc( 2 * pn->rg_len * sizeof(rg_entry_t)))) { /* recover the old pointer to be able to shm_free mem */ SHM_MEM_ERROR; @@ -285,7 +289,8 @@ int add_dst(rt_data_t *r, pgw = (pgw_t *)shm_malloc(sizeof(pgw_t) + l_ip + l_pri + l_attrs); if(NULL == pgw) { SHM_MEM_ERROR_FMT("missing (%u)\n", -- (unsigned int)(sizeof(pgw_t) + l_ip + l_pri + l_attrs));; + -(unsigned int)(sizeof(pgw_t) + l_ip + l_pri + l_attrs)); + ; goto err_exit; } memset(pgw, 0, sizeof(pgw_t));