- fixed almost all warnings in ser core (gcc-3.0 -Wall, icc, sun cc).
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Sat, 2 Mar 2002 02:20:00 +0000 (02:20 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Sat, 2 Mar 2002 02:20:00 +0000 (02:20 +0000)
(=> fixed a lot of format string bugs)
- replaced some of the remaining mallocs w/ pkg_malloc

28 files changed:
Makefile.defs
Makefile.rules
action.c
cfg.y
data_lump.c
data_lump_rpl.c
data_lump_rpl.h
forward.c
main.c
md5.c
md5utils.c
mem/f_malloc.c
mem/mem.c
mem/shm_mem.c
modules/tm/t_fwd.c
modules/tm/t_reply.c
msg_parser.c
msg_translator.c
parse_hname.c
parse_to.c
parse_via.c
proxy.c
receive.c
route.c
route_struct.c
sr_module.c
udp_server.c
ut.h

index dfe4540..8c17235 100644 (file)
@@ -171,7 +171,7 @@ ifeq        ($(ARCH), i386)
 ifeq           ($(CC_NAME), gcc)
                                #common stuff
                                CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
-                                       #-Wmissing-prototypes \
+                                       -Wall #-Wmissing-prototypes \
                        #if gcc 3.0
 ifeq                   ($(CC_SHORTVER), 3.0)
                                        CFLAGS+=-minline-all-stringops -malign-double \
index bb361ab..8fa450b 100644 (file)
@@ -39,7 +39,7 @@ static: $(objs)
 
 .PHONY: clean
 clean:
-       -@rm -f $(objs) $(NAME) 2>/dev/null
+       -@rm -f $(objs) $(NAME) $(objs:.o=.il) 2>/dev/null
        -@for r in $(modules) $(static_modules_path) "" ; do \
                if [ -n "$$r" ]; then \
                        echo "module $$r" ; \
index a2aeeda..98aec07 100644 (file)
--- a/action.c
+++ b/action.c
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <string.h>
 
 #ifdef DEBUG_DMALLOC
 #include <dmalloc.h>
@@ -77,7 +78,7 @@ int do_action(struct action* a, struct sip_msg* msg)
                                                                                if (err){
                                                                                        LOG(L_ERR, "ERROR: do_action: "
                                                                                                        "forward: bad port in "
-                                                                                                       "uri: <%s>\n", uri.port);
+                                                                                                       "uri: <%s>\n", uri.port.s);
                                                                                        ret=E_UNSPEC;
                                                                                        goto error_fwd_uri;
                                                                                }
@@ -369,7 +370,7 @@ int do_action(struct action* a, struct sip_msg* msg)
                default:
                        LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type);
        }
-skip:
+/*skip:*/
        return ret;
        
 error_uri:
@@ -389,7 +390,7 @@ error_fwd_uri:
 int run_actions(struct action* a, struct sip_msg* msg)
 {
        struct action* t;
-       int ret;
+       int ret=E_UNSPEC;
        static int rec_lev=0;
        struct sr_module *mod;
 
diff --git a/cfg.y b/cfg.y
index 0eb3a73..b748ed4 100644 (file)
--- a/cfg.y
+++ b/cfg.y
@@ -24,6 +24,7 @@
 #include <dmalloc.h>
 #endif
 
+extern int yylex();
 void yyerror(char* s);
 char* tmp;
 void* f_tmp;
index 02f08ae..fba7eb2 100644 (file)
@@ -7,6 +7,7 @@
 #include "mem/mem.h"
 
 #include <stdlib.h>
+#include <string.h>
 
 #ifdef DEBUG_DMALLOC
 #include <dmalloc.h>
index 62a050a..1541886 100644 (file)
@@ -1,5 +1,5 @@
 
-
+#include <string.h>
 #include "dprint.h"
 #include "mem/mem.h"
 #include "data_lump_rpl.h"
@@ -36,7 +36,7 @@ error:
 
 
 
-int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump)
+void add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump)
 {
        struct lump_rpl *foo;
 
@@ -51,7 +51,7 @@ int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump)
 
 
 
-int free_lump_rpl(struct lump_rpl* lump)
+void free_lump_rpl(struct lump_rpl* lump)
 {
        if (lump && lump->text.s)  pkg_free(lump->text.s);
        if (lump) pkg_free(lump);
index 431ccb4..93f680e 100644 (file)
@@ -17,8 +17,8 @@ struct lump_rpl
 
 struct lump_rpl* build_lump_rpl( char* , int );
 
-int add_lump_rpl(struct sip_msg * , struct lump_rpl* );
+void add_lump_rpl(struct sip_msg * , struct lump_rpl* );
 
-int free_lump_rpl(struct lump_rpl* );
+void free_lump_rpl(struct lump_rpl* );
 
 #endif
index d7120df..0360b73 100644 (file)
--- a/forward.c
+++ b/forward.c
@@ -82,12 +82,12 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
        }
        /* sent requests stats */
        else STATS_TX_REQUEST(  msg->first_line.u.request.method_value );
-       free(buf);
+       pkg_free(buf);
        free(to);
        /* received_buf & line_buf will be freed in receiv_msg by free_lump_list*/
        return 0;
 error:
-       if (buf) free(buf);
+       if (buf) pkg_free(buf);
        if (to) free(to);
        return -1;
 }
@@ -131,12 +131,7 @@ int forward_reply(struct sip_msg* msg)
        struct sockaddr_in* to;
        unsigned int new_len;
        struct sr_module *mod;
-#ifdef DNS_IP_HACK
-       int err;
-#endif
-
-
-
+       
        to=0;
        new_buf=0;
        /*check if first via host = us */
@@ -145,7 +140,7 @@ int forward_reply(struct sip_msg* msg)
                        if(strcmp(msg->via1->host.s, names[r])==0) break;
                if (r==addresses_no){
                        LOG(L_NOTICE, "ERROR: forward_reply: host in first via!=me :"
-                                       " %s\n", msg->via1->host);
+                                       " %s\n", msg->via1->host.s);
                        /* send error msg back? */
                        goto error;
                }
@@ -198,12 +193,12 @@ int forward_reply(struct sip_msg* msg)
        DBG(" reply forwarded to %s:%d\n",msg->via2->host.s,
                (unsigned short) msg->via2->port);
 
-       free(new_buf);
+       pkg_free(new_buf);
        free(to);
 skip:
        return 0;
 error:
-       if (new_buf) free(new_buf);
+       if (new_buf) pkg_free(new_buf);
        if (to) free(to);
        return -1;
 }
diff --git a/main.c b/main.c
index e2d1dac..b8a3baf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -591,8 +591,8 @@ int main(int argc, char** argv)
                                        printf("flags: %s\n", flags );
                                        print_ct_constants();
                                        printf("%s\n",id);
-                                       printf("%s compiled on %s at %s with %s\n", __FILE__,
-                                                       __DATE__, __TIME__, COMPILER );
+                                       printf("%s compiled on %s with %s\n", __FILE__,
+                                                       compiled, COMPILER );
                                        
                                        exit(0);
                                        break;
diff --git a/md5.c b/md5.c
index 11801f3..379d7f8 100644 (file)
--- a/md5.c
+++ b/md5.c
@@ -23,9 +23,11 @@ These notices must be retained in any copies of any part of this
 documentation and/or software.
  */
 
+#include <string.h>
 #include "md5global.h"
 #include "md5.h"
 
+
 #define USE_MEM
 
 /* Constants for MD5Transform routine.
index d6ab9f9..b6e7e69 100644 (file)
@@ -32,7 +32,7 @@ jku: added support to deal with vectors
 #include "ut.h"
 
 
-static void MDString PROTO_LIST ((char *));
+/*static void MDString PROTO_LIST ((char *));*/
 
 #define MD_CTX MD5_CTX
 #define MDInit MD5Init
index 1078fbc..effc1ab 100644 (file)
@@ -4,6 +4,8 @@
 
 #if !defined(q_malloc) && !(defined VQ_MALLOC) 
 
+#include <string.h>
+
 #include "f_malloc.h"
 #include "../dprint.h"
 
@@ -87,7 +89,6 @@ struct fm_block* fm_malloc_init(char* address, unsigned int size)
        char* end;
        struct fm_block* qm;
        unsigned int init_overhead;
-       int h;
        
        /* make address and size multiple of 8*/
        start=(char*)ROUNDUP((unsigned int) address);
@@ -261,7 +262,7 @@ void fm_status(struct fm_block* qm)
        int h;
        int size;
 
-       LOG(L_INFO, "fm_status (%x):\n", qm);
+       LOG(L_INFO, "fm_status (%p):\n", qm);
        if (!qm) return;
 
        LOG(L_INFO, " heap size= %d\n", qm->size);
index 0ad942d..9e116f4 100644 (file)
--- a/mem/mem.c
+++ b/mem/mem.c
@@ -7,11 +7,15 @@
 #include "mem.h"
 
 #ifdef PKG_MALLOC
-#      ifdef VQ_MALLOC
-#              include "vq_malloc.h"
-#      else
-#              include "q_malloc.h"
-#      endif
+       #ifdef VQ_MALLOC
+               #include "vq_malloc.h"
+       #else
+               #include "q_malloc.h"
+       #endif
+#endif
+
+#ifdef SHM_MEM
+#include "shm_mem.h"
 #endif
 
 #ifdef PKG_MALLOC
index c26d514..70f31c9 100644 (file)
@@ -82,7 +82,7 @@ void* _shm_resize( void* p, unsigned int s, char* file, char* func, unsigned int
 void* _shm_resize( void* p , unsigned int s)
 #endif
 {
-       char *c;
+       
 #ifdef VQ_MALLOC
        struct vqm_frag *f;
 #else
@@ -125,13 +125,14 @@ void* _shm_resize( void* p , unsigned int s)
 int shm_mem_init()
 {
 
+#ifndef FAST_LOCK
        union semun su;
+#endif
 #ifdef SHM_MMAP
        int fd;
 #else
        struct shmid_ds shm_info;
 #endif
-       int ret;
 
 #ifdef SHM_MMAP
        if (shm_mempool && (shm_mempool!=(void*)-1)){
index 29c398e..f35f934 100644 (file)
@@ -112,7 +112,7 @@ int t_forward_nonack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
                T->outbound_request[branch] = rb;
                SEND_BUFFER( rb );
                /* link the retransmission buffer to our structures when the job is done */
-               free( buf ) ; buf=NULL;
+               pkg_free( buf ) ; buf=NULL;
 
                DBG("DEBUG: t_forward_nonack: starting timers (retrans and FR) %d\n",get_ticks() );
                /*sets and starts the FINAL RESPONSE timer */
@@ -154,7 +154,7 @@ error:
                shm_free(rb);
                T->outbound_request[branch]=NULL;
        }
-       if (buf) free( buf );
+       if (buf) pkg_free( buf );
 
        return -1;
 
@@ -222,7 +222,7 @@ int t_forward_ack( struct sip_msg* p_msg , unsigned int dest_ip_param ,
        shm_unlock();
 
        memcpy( (char *) srb + sizeof ( struct retrans_buff ), buf, len );
-       free( buf );
+       pkg_free( buf );
 
        relay_ack( T, branch, srb, len );
        return 1;
index ffbb480..1dddaab 100644 (file)
@@ -106,7 +106,7 @@ int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
 
        SEND_PR_BUFFER( rb, buf, len );
 
-       free( buf ) ;
+       pkg_free( buf ) ;
        /* start/stops the proper timers*/
 
        DBG("DEBUG: t_send_reply: finished\n");
@@ -114,7 +114,7 @@ int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
        return 1;
 
 error2:
-       free ( buf );
+       pkg_free ( buf );
 error:
        return -1;
 }
@@ -385,7 +385,7 @@ cleanup:
 error2:
        if (start_fr) 
                set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
-       if (buf) free( buf );
+       if (buf) pkg_free( buf );
 error1:
        if (!save_clone) sip_msg_free( clone );
 error:
index 29c0498..19eb876 100644 (file)
@@ -174,9 +174,10 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
 error:
        LOG(L_INFO, "ERROR:parse_first_line: bad %s first line\n",
                (fl->type==SIP_REPLY)?"reply(status)":"request");
+       LOG(L_INFO, "ERROR: at line 0 char %d\n", offset);
 error1:
        fl->type=SIP_INVALID;
-       LOG(L_INFO, "ERROR: at line 0 char %d\n", offset);
+       LOG(L_INFO, "ERROR:parse_first_line: bad message\n");
        /* skip  line */
        nl=eat_line(buffer,len);
        return nl;
@@ -677,7 +678,7 @@ error:
 int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
 {
 
-       char *tmp, *bar;
+       char *tmp;
        char* rest;
        char* first_via;
        char* second_via;
@@ -717,6 +718,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
                        break;
                default:
                        DBG("unknown type %d\n",fl->type);
+                       goto error;
        }
        msg->unparsed=tmp;
        /*find first Via: */
index e0a287a..f2c918b 100644 (file)
@@ -4,6 +4,8 @@
 
 
 #include <sys/socket.h>
+#include <netdb.h>
+#include <string.h>
 
 #include "msg_translator.h"
 #include "mem/mem.h"
 #include "config.h"
 #include "md5utils.h"
 #include "data_lump_rpl.h"
-#include <netdb.h>
 
 
 
 #define MAX_VIA_LINE_SIZE      240
 #define MAX_RECEIVED_SIZE  57
 
+/* mallocs for local stuff (not needed to be shared mem?)*/
+#define local_malloc pkg_malloc
+#define local_free   pkg_free
+
 
 #define append_str(_dest,_src,_len,_msg) \
        do{\
@@ -114,7 +119,6 @@ int check_address(unsigned long ip, char *name, int resolver)
        }
        if (resolver&DO_REV_DNS){
                DBG("check_address: doing rev. dns lookup\n");
-               print_ip(ip);
                /* try reverse dns */
                he=gethostbyaddr((char*)&ip, sizeof(ip), AF_INET);
                if (he && (strcmp(he->h_name, name)==0))
@@ -232,6 +236,7 @@ char * build_req_buf_from_sip_req(  struct sip_msg* msg,
        struct lump *t,*r;
        struct lump* anchor;
 
+       uri_len=0;
        orig=msg->orig;
        buf=msg->buf;
        len=msg->len;
@@ -332,7 +337,7 @@ char * build_req_buf_from_sip_req(  struct sip_msg* msg,
                                        s_offset=t->u.offset;
                                /* do nothing */
                                break;
-                       debug:
+                       default:
                                LOG(L_CRIT,"BUG:build_req_buf_from_sip_req: invalid"
                                                        " op for data lump (%x)\n", r->op);
                }
@@ -354,7 +359,7 @@ char * build_req_buf_from_sip_req(  struct sip_msg* msg,
                uri_len=msg->new_uri.len;
                new_len=new_len-msg->first_line.u.request.uri.len+uri_len;
        }
-       new_buf=(char*)malloc(new_len+1);
+       new_buf=(char*)local_malloc(new_len+1);
        if (new_buf==0){
                LOG(L_ERR, "ERROR: build_req_buf_from_sip_req: out of memory\n");
                goto error;
@@ -477,7 +482,7 @@ error1:
        if (received_buf) pkg_free(received_buf);
        if (line_buf) pkg_free(line_buf);
 error:
-       if (new_buf) free(new_buf);
+       if (new_buf) local_free(new_buf);
        *returned_len=0;
        return 0;
 }
@@ -488,10 +493,9 @@ error:
 char * build_res_buf_from_sip_res( struct sip_msg* msg,
                                unsigned int *returned_len)
 {
-       unsigned int new_len, via_len,r;
+       unsigned int new_len, via_len;
        char* new_buf;
        unsigned offset, s_offset, size;
-       struct hostent* he;
        char* orig;
        char* buf;
        unsigned int len;
@@ -516,7 +520,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
        new_len=len-via_len;
 
        DBG(" old size: %d, new size: %d\n", len, new_len);
-       new_buf=(char*)malloc(new_len+1);/* +1 is for debugging
+       new_buf=(char*)local_malloc(new_len+1);/* +1 is for debugging
                                                                                        (\0 to print it )*/
        if (new_buf==0){
                LOG(L_ERR, "ERROR: build_res_buf_from_sip_res: out of memory\n");
@@ -535,7 +539,7 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
        *returned_len=new_len;
        return new_buf;
 error:
-       if (new_buf) free(new_buf);
+       if (new_buf) local_free(new_buf);
        *returned_len=0;
        return 0;
 }
@@ -596,7 +600,7 @@ char * build_res_buf_from_sip_req(  unsigned int code ,
        len += CRLF_LEN; /*new line*/
        /*allocating mem*/
        buf = 0;
-       buf = (char*) malloc( len+1 );
+       buf = (char*) local_malloc( len+1 );
        if (!buf)
        {
                LOG(L_ERR, "ERROR: build_res_buf_from_sip_req: out of memory "
@@ -677,7 +681,7 @@ char * build_res_buf_from_sip_req(  unsigned int code ,
        *returned_len = len;
        return buf;
 error:
-       if (buf) free(buf);
+       if (buf) local_free(buf);
        *returned_len=0;
        return 0;
 }
index 891f652..e1b7b56 100644 (file)
@@ -50,7 +50,6 @@ char* parse_hname1(char* p, char* end, struct hdr_field* hdr)
 
        char* t;
        register int state;
-       int i;
        int err;
        err=0;
 
index ec10584..3637b6f 100644 (file)
@@ -1,6 +1,7 @@
 
 
 #include <stdlib.h>
+#include <string.h>
 #include "dprint.h"
 #include "msg_parser.h"
 #include "ut.h"
@@ -35,11 +36,15 @@ enum{ S_PARA_NAME=20, PARA_NAME, S_EQUAL, S_PARA_VALUE, TAG1, TAG2, TAG3
 char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
                                                                int *returned_status)
 {
-       struct to_param *param=0;
-       int status =PARA_START;
+       struct to_param *param;
+       int status;
        int saved_status;
        char  *tmp;
 
+       param=0;
+       status=PARA_START;
+       saved_status=PARA_START;
+
        for( tmp=buffer; tmp<end; tmp++)
        {
                switch(*tmp)
@@ -389,11 +394,13 @@ error:
 
 char* parse_to(char* buffer, char *end, struct to_body *to_b)
 {
-       struct to_param *param=0;
-       int status = START_TO;
+       int status;
        int saved_status;
        char  *tmp,*foo;
 
+       status=START_TO;
+       foo=0;
+
        for( tmp=buffer; tmp<end; tmp++)
        {
                switch(*tmp)
index 3af9b76..0584b1d 100644 (file)
@@ -18,6 +18,7 @@
 
 
 #include <stdlib.h>
+#include <string.h>
 #include "dprint.h"
 #include "msg_parser.h"
 #include "ut.h"
@@ -208,7 +209,7 @@ char* parse_via_param(      char* p, char* end, int* pstate,
                                        case F_PARAM:
                                        case FIN_HIDDEN:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in"
-                                                               " state %d\n");
+                                                               " state %d\n", *tmp, state);
                                                goto error;
                                        case F_CR:
                                        case F_LF:
@@ -237,7 +238,7 @@ char* parse_via_param(      char* p, char* end, int* pstate,
                                        case FIN_TTL:
                                        case FIN_RECEIVED:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c> in"
-                                                               " state %d\n");
+                                                               " state %d\n", *tmp, state);
                                                goto error;
                                        case F_CR:
                                        case F_LF:
@@ -585,7 +586,7 @@ goto error;
 
 find_value:
        tmp++;
-       for(tmp;*tmp;tmp++){
+       for(;*tmp;tmp++){
                switch(*tmp){
                        case ' ':
                        case '\t':
@@ -607,7 +608,7 @@ find_value:
                                                break;
                                        default:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
-                                                               " in state %d\n", state);
+                                                               " in state %d\n", *tmp, state);
                                                goto error;
                                }
                                break;
@@ -634,7 +635,7 @@ find_value:
                                                break;
                                        default:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
-                                                               " in state %d\n", state);
+                                                               " in state %d\n", *tmp, state);
                                                goto error;
                                }
                                break;
@@ -659,7 +660,7 @@ find_value:
                                                goto end_via;
                                        default:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
-                                                               " in state %d\n", state);
+                                                               " in state %d\n", *tmp, state);
                                                goto error;
                                }
                                break;
@@ -678,7 +679,7 @@ find_value:
                                                goto end_via;
                                        default:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
-                                                               " in state %d\n", state);
+                                                               " in state %d\n", *tmp, state);
                                                goto error;
                                }
                                break;
@@ -698,7 +699,7 @@ find_value:
                                                goto end_via;
                                        default:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
-                                                               " in state %d\n", state);
+                                                               " in state %d\n", *tmp, state);
                                                goto error;
                                }
                                break;
@@ -717,7 +718,7 @@ find_value:
                                                goto end_via;
                                        default:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
-                                                               " in state %d\n", state);
+                                                               " in state %d\n", *tmp, state);
                                                goto error;
                                }
                                break; /* what to do? */
@@ -739,7 +740,7 @@ find_value:
                                                goto end_via;
                                        default:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
-                                                               " in state %d\n", state);
+                                                               " in state %d\n", *tmp, state);
                                                goto error;
                                }
                                break;
@@ -759,7 +760,7 @@ find_value:
                                                goto end_via;
                                        default:
                                                LOG(L_ERR, "ERROR: parse_via: invalid char <%c>"
-                                                               " in state %d\n", state);
+                                                               " in state %d\n", *tmp, state);
                                                goto error;
                                }
                }
@@ -805,10 +806,8 @@ char* parse_via(char* buffer, char* end, struct via_body *vb)
        int state;
        int saved_state;
        int c_nest;
-       int i;
        int err;
 
-       char* tmp_param;
        struct via_param* param;
 
 parse_again:
diff --git a/proxy.c b/proxy.c
index 64e028e..a748765 100644 (file)
--- a/proxy.c
+++ b/proxy.c
@@ -139,7 +139,6 @@ void free_hostent(struct hostent *dst)
 struct proxy_l* add_proxy(char* name, unsigned short port)
 {
        struct proxy_l* p;
-       struct hostent* he;
        
        if ((p=find_proxy(name, port))!=0) return p;
        if ((p=mk_proxy(name, port))==0) goto error;
@@ -234,8 +233,6 @@ error:
 struct proxy_l* mk_proxy_from_ip(unsigned int ip, unsigned short port)
 {
        struct proxy_l* p;
-       struct hostent* he;
-       int err;
 
        p=(struct proxy_l*) malloc(sizeof(struct proxy_l));
        if (p==0){
index bf7a294..7b902d4 100644 (file)
--- a/receive.c
+++ b/receive.c
@@ -96,12 +96,13 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
                        LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n");
                        goto error;
                }
-               /*
+#if 0
                if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK)){
-                       /* no second via => error? /
+                       /* no second via => error? */
                        LOG(L_ERR, "ERROR: receive_msg: no 2nd via found in reply\n");
                        goto error;
-               }*/
+               }
+#endif
                /* check if via1 == us */
 
 #ifdef STATS
diff --git a/route.c b/route.c
index 0851782..845b0e6 100644 (file)
--- a/route.c
+++ b/route.c
@@ -273,8 +273,6 @@ static int comp_ip(unsigned a, void* param, int op, int subtype)
        }
        return ret;
        
-error:
-       return -1;
 }
 
 
index e09cb3a..775ff6d 100644 (file)
@@ -11,6 +11,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <netinet/in.h>
+#include <string.h>
 
 #include "dprint.h"
 
index 698a0dd..375419b 100644 (file)
@@ -8,6 +8,7 @@
 #include <dlfcn.h>
 #include <strings.h>
 #include <stdlib.h>
+#include <string.h>
 
 
 struct sr_module* modules=0;
@@ -32,24 +33,34 @@ struct sr_module* modules=0;
 /* initializes statically built (compiled in) modules*/
 int init_builtin_modules()
 {
+       int ret;
+
+       ret=0;
        #ifdef STATIC_TM
-               register_module(tm_mod_register,"built-in", 0);
+               ret=register_module(tm_mod_register,"built-in", 0);
+               if (ret<0) return ret;
        #endif
        #ifdef STATIC_MAXFWD
-               register_module(maxfwd_mod_register, "built-in", 0);
+               ret=register_module(maxfwd_mod_register, "built-in", 0);
+               if (ret<0) return ret;
        #endif
 
 #ifdef STATIC_AUTH
-               register_module(tm_mod_register, "built-in", 0);
+               ret=register_module(tm_mod_register, "built-in", 0);
+               if (ret<0) return ret;
 #endif
 
 #ifdef STATIC_RR
-               register_module(rr_mod_register, "built-in", 0);
+               ret=register_module(rr_mod_register, "built-in", 0);
+               if (ret<0) return ret;
 #endif
 
 #ifdef STATIC_USRLOC
-               register_module(usrloc_mod_register, "built-in", 0);
+               ret=register_module(usrloc_mod_register, "built-in", 0);
+               if (ret<0) return ret;
 #endif
+       
+       return ret;
 }
 
 
@@ -60,7 +71,7 @@ int register_module(module_register register_f, char* path, void* handle)
 {
        int ret;
        struct module_exports* e;
-       struct sr_module* t, *mod;
+       struct sr_module* mod;
        
        ret=-1;
        e=(*register_f)();
@@ -95,7 +106,8 @@ int init_child(int rank)
        for(t = modules; t; t = t->next) {
                if (t->exports->init_child_f) {
                        if ((t->exports->init_child_f(rank)) < 0) {
-                               LOG(L_ERR, "init_child(): Initialization of child with rank %d failed\n");
+                               LOG(L_ERR, "init_child(): Initialization of child %d failed\n",
+                                               rank);
                                return -1;
                        }
                }
index e6041a2..ce0d2fd 100644 (file)
@@ -25,14 +25,13 @@ int udp_sock;
 
 int probe_max_receive_buffer( int udp_sock )
 {
-       int optval, optvallen;
+       int optval;
        int ioptval;
        unsigned int ioptvallen;
        int foptval;
        unsigned int foptvallen;
        int voptval;
        unsigned int voptvallen;
-       int i;
        int phase=0;
 
        /* jku: try to increase buffer size as much as we can */
@@ -52,20 +51,21 @@ int probe_max_receive_buffer( int udp_sock )
        for (optval=ioptval; ;  ) {
                /* increase size; double in initial phase, add linearly later */
                if (phase==0) optval <<= 1; else optval+=BUFFER_INCREMENT;
-               if (optval > maxbuffer) if (phase==1) break; else { phase=1; optval >>=1; continue; }
+               if (optval > maxbuffer){
+                       if (phase==1) break; 
+               } else { phase=1; optval >>=1; continue; }
                LOG(L_DBG, "DEBUG: udp_init: trying SO_RCVBUF: %d\n", optval );
-               if (setsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF,
-                             (void*)&optval, sizeof(optval)) ==-1)
-               {
+               if (setsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF,
+                       (void*)&optval, sizeof(optval)) ==-1){
                        /* Solaris returns -1 if asked size too big; Linux ignores */
-                       LOG(L_DBG, "DEBUG: udp_init: SOL_SOCKET failed for %d, phase %d: %s\n",
-                           optval,  phase, strerror(errno) );
+                       LOG(L_DBG, "DEBUG: udp_init: SOL_SOCKET failed"
+                                       " for %d, phase %d: %s\n", optval, phase, strerror(errno));
                        /* if setting buffer size failed and still in the aggressive
                           phase, try less agressively; otherwise give up 
                        */
                        if (phase==0) { phase=1; optval >>=1 ; continue; } 
                        else break;
-               } 
+               } 
                /* verify if change has taken effect */
                /* Linux note -- otherwise I would never know that; funny thing: Linux
                   doubles size for which we asked in setsockopt
@@ -82,13 +82,13 @@ int probe_max_receive_buffer( int udp_sock )
                        if (voptval<optval) {
                                LOG(L_DBG, "DEBUG: setting SO_RCVBUF has no effect\n");
                                /* if setting buffer size failed and still in the aggressive
-                               phase, try less agressively; otherwise give up 
+                               phase, try less agressively; otherwise give up 
                                */
-                               if (phase==0) { phase=1; optval >>=1 ; continue; } 
-                               else break;
+                               if (phase==0) { phase=1; optval >>=1 ; continue; } 
+                               else break;
                        } 
                }
-
+       
        } /* for ... */
        foptvallen=sizeof(foptval);
        if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &foptval,
@@ -97,7 +97,7 @@ int probe_max_receive_buffer( int udp_sock )
                LOG(L_ERR, "ERROR: udp_init: getsockopt: %s\n", strerror(errno));
                return -1;
        }
-       LOG(L_INFO, "INFO: udp_init: SO_RCVBUF is finally %d\n", foptval );
+       LOG(L_INFO, "INFO: udp_init: SO_RCVBUF is finally %d\n", foptval );
 
        return 0;
 
@@ -107,7 +107,7 @@ int probe_max_receive_buffer( int udp_sock )
 int udp_init(unsigned long ip, unsigned short port)
 {
        struct sockaddr_in* addr;
-       int optval, optvallen;
+       int optval;
 
 
        addr=(struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
@@ -261,7 +261,7 @@ again:
        n=sendto(udp_sock, buf, len, 0, to, tolen);
 /*     n=sendto(udp_sock, buf, len, 0, &a2, sizeof(struct sockaddr_in) );*/
        if (n==-1){
-               LOG(L_ERR, "ERROR: udp_send: sendto(sock,%x,%d,0,%x,%d): %s(%d)\n",
+               LOG(L_ERR, "ERROR: udp_send: sendto(sock,%p,%d,0,%p,%d): %s(%d)\n",
                                buf,len,to,tolen,
                                strerror(errno),errno);
                if (errno==EINTR) goto again;
diff --git a/ut.h b/ut.h
index 80b938f..fc684dd 100644 (file)
--- a/ut.h
+++ b/ut.h
@@ -24,7 +24,9 @@
 
 #define trim_r( _mystr ) \
        do{     static char _c; \
-               while( ((_mystr).len) && ((_c=(_mystr).s[(_mystr).len-1]))==0 || _c=='\r' || _c=='\n') \
+               while( ((_mystr).len) && ( ((_c=(_mystr).s[(_mystr).len-1]))==0 ||\
+                                                                       _c=='\r' || _c=='\n' ) \
+                               ) \
                        (_mystr).len--; \
        }while(0)