Skip to content

Commit

Permalink
drouting: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent b16014e commit f52dd52
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/modules/drouting/dr_load.c
Expand Up @@ -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) { \
Expand Down
37 changes: 16 additions & 21 deletions src/modules/drouting/dr_time.c
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
22 changes: 12 additions & 10 deletions src/modules/drouting/drouting.c
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
15 changes: 10 additions & 5 deletions src/modules/drouting/routing.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit f52dd52

Please sign in to comment.