diff --git a/src/modules/ctl/binrpc.c b/src/modules/ctl/binrpc.c index e7454becefa..6239f6d2928 100644 --- a/src/modules/ctl/binrpc.c +++ b/src/modules/ctl/binrpc.c @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/src/modules/ctl/binrpc_run.c b/src/modules/ctl/binrpc_run.c index 387b3aa4c7d..9054ef5a71e 100644 --- a/src/modules/ctl/binrpc_run.c +++ b/src/modules/ctl/binrpc_run.c @@ -13,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -1052,7 +1052,7 @@ static int rpc_struct_add(struct rpc_struct_l* s, char* fmt, ...) int err; struct binrpc_val avp; struct rpc_struct_l* rs; - + va_start(ap, fmt); for (;*fmt; fmt++){ memset(&avp, 0, sizeof(struct binrpc_val)); @@ -1081,26 +1081,37 @@ static int rpc_struct_add(struct rpc_struct_l* s, char* fmt, ...) case '[': avp.type=BINRPC_T_STRUCT; err=binrpc_addavp(&s->pkt, &avp); - if (err<0) goto error_add; + if (err<0){ + LM_ERR("failed to add attribute-value\n"); + goto error_add; + } rs=new_rpc_struct(); - if (rs==0) goto error_mem; + if (rs==0){ + LM_ERR("not enough memory\n"); + goto error_mem; + } rs->offset=binrpc_pkt_len(&s->pkt); err=binrpc_end_struct(&s->pkt); - if (err<0) goto error_add; + if (err<0) { + LM_ERR("failed to end struct\n"); + goto error_add; + } clist_append(&s->substructs, rs, next, prev); *(va_arg(ap, void**))=rs; goto end; - case 'f': + case 'f': avp.type=BINRPC_T_DOUBLE; avp.u.fval=va_arg(ap, double); break; - default: - LOG(L_CRIT, "BUG: binrpc: rpc_struct_add: formatting char" - " \'%c\'" " not supported\n", *fmt); + default: + LM_ERR("formatting char \'%c\'" " not supported\n", *fmt); goto error; } err=binrpc_addavp(&s->pkt, &avp); - if (err<0) goto error; + if (err<0) { + LM_ERR("failed to add attribute-value\n"); + goto error; + } } end: va_end(ap); @@ -1120,7 +1131,7 @@ static int rpc_array_add(struct rpc_struct_l* s, char* fmt, ...) char* sv; str* st; struct rpc_struct_l* rs; - + va_start(ap, fmt); for (;*fmt; fmt++){ switch(*fmt){ @@ -1134,7 +1145,7 @@ static int rpc_array_add(struct rpc_struct_l* s, char* fmt, ...) case 's': /* asciiz */ sv=va_arg(ap, char*); if (sv==0) /* fix null strings */ - sv=""; + sv=""; err=binrpc_addstr(&s->pkt, sv, strlen(sv)); if (err<0) goto error_add; break; @@ -1155,11 +1166,11 @@ static int rpc_array_add(struct rpc_struct_l* s, char* fmt, ...) clist_append(&s->substructs, rs, next, prev); *(va_arg(ap, void**))=rs; break; - case 'f': + case 'f': err=binrpc_adddouble(&s->pkt, va_arg(ap, double)); if (err<0) goto error_add; break; - default: + default: LOG(L_CRIT, "BUG: binrpc: rpc_add: formatting char \'%c\'" " not supported\n", *fmt); goto error; diff --git a/src/modules/ctl/ctl.c b/src/modules/ctl/ctl.c index 5a79fba9fa3..f15c721ad21 100644 --- a/src/modules/ctl/ctl.c +++ b/src/modules/ctl/ctl.c @@ -14,8 +14,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -57,7 +57,7 @@ static int usock_gid=-1; /* if set try to automatically convert values to the requested type in rpc->scan (default: not set) */ -extern int autoconvert; +extern int autoconvert; extern int binrpc_max_body_size; extern int binrpc_struct_max_body_size; @@ -96,7 +96,7 @@ static param_export_t params[]={ {"autoconversion", PARAM_INT, &autoconvert }, {"binrpc_max_body_size", PARAM_INT, &binrpc_max_body_size }, {"binrpc_struct_max_body_size", PARAM_INT, &binrpc_struct_max_body_size }, - {0,0,0} + {0,0,0} }; /* no params */ struct module_exports exports= { @@ -121,7 +121,7 @@ static int add_binrpc_socket(modparam_t type, void * val) { char *s; struct id_list* id; - + if ((type & PARAM_STRING)==0){ LOG(L_CRIT, "BUG: ctl: add_binrpc_socket: bad parameter type %d\n", type); @@ -148,7 +148,7 @@ static int add_fifo_socket(modparam_t type, void * val) { char *s; struct id_list* id; - + if ((type & PARAM_STRING)==0){ LOG(L_CRIT, "BUG: ctl: add_fifo: bad parameter type %d\n", type); @@ -174,7 +174,7 @@ static int add_fifo_socket(modparam_t type, void * val) static int fix_user(modparam_t type, void * val) { char* s; - + if ((type & PARAM_STRING)==0){ LOG(L_CRIT, "BUG: ctl: fix_user: bad parameter type %d\n", type); @@ -195,7 +195,7 @@ static int fix_user(modparam_t type, void * val) static int fix_group(modparam_t type, void * val) { char* s; - + if ((type & PARAM_STRING)==0){ LOG(L_CRIT, "BUG: ctl: fix_group: bad parameter type %d\n", type); @@ -257,7 +257,7 @@ static int mod_init(void) payload_proto_name(l->data_proto), l->name); break; case UDP_SOCK: - DBG(" [%s:udp] %s:%d\n", + DBG(" [%s:udp] %s:%d\n", payload_proto_name(l->data_proto), l->name, l->port?l->port:DEFAULT_CTL_PORT); break; @@ -310,7 +310,7 @@ static int mod_child(int rank) int pid; struct ctrl_socket* cs; static int rpc_handler=0; - + /* do nothing from PROC_INIT, is the same as PROC_MAIN */ if (rank==PROC_INIT) return 0; @@ -325,7 +325,7 @@ static int mod_child(int rank) pid=fork_process(PROC_RPC, "ctl handler", 1); DBG("ctl: mod_child(%d), fork_process=%d, csl=%p\n", rank, pid, ctrl_sock_lst); - if (pid<0){ + if (pid<0){ goto error; } if (pid == 0){ /* child */ @@ -368,7 +368,7 @@ static int mod_child(int rank) static void mod_destroy(void) { struct ctrl_socket* cs; - + /* close all the opened fds & unlink the files */ for (cs=ctrl_sock_lst; cs; cs=cs->next){ switch(cs->transport){ @@ -416,7 +416,7 @@ static void mod_destroy(void) static void ctrl_listen_ls_rpc(rpc_t* rpc, void* ctx) { struct ctrl_socket* cs; - + for (cs=ctrl_sock_lst; cs; cs=cs->next){ rpc->add(ctx, "ssss", payload_proto_name(cs->p_proto), socket_proto_name(cs->transport),