瀏覽代碼

- lots of fixes (alignments, casts, warnings)
- it compiles cleanly now wit sun cc and intel icc.
- slight api change for param_func_t (it takes a void* now instead of
a param_func_param_t)

Andrei Pelinescu-Onciul 21 年之前
父節點
當前提交
d7a3fdead7
共有 14 個文件被更改,包括 39 次插入41 次删除
  1. 1 1
      Makefile.defs
  2. 1 1
      data_lump_rpl.c
  3. 8 8
      db/db_fifo.c
  4. 2 1
      dset.c
  5. 2 2
      main.c
  6. 1 2
      modparam.c
  7. 10 9
      modules/tm/t_fifo.c
  8. 1 1
      modules/tm/t_fifo.h
  9. 1 1
      modules/tm/t_funcs.c
  10. 2 2
      modules/tm/t_funcs.h
  11. 1 1
      modules/tm/t_hooks.c
  12. 1 1
      modules/tm/t_reply.c
  13. 7 10
      sr_module.h
  14. 1 1
      unixsock_server.c

+ 1 - 1
Makefile.defs

@@ -50,7 +50,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 8
 SUBLEVEL =   99
-EXTRAVERSION = -dev22
+EXTRAVERSION = -dev23
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 1 - 1
data_lump_rpl.c

@@ -101,7 +101,7 @@ error:
 
 
 
-inline void free_lump_rpl(struct lump_rpl* lump)
+void free_lump_rpl(struct lump_rpl* lump)
 {
 	if (lump) {
 		if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP)

+ 8 - 8
db/db_fifo.c

@@ -383,9 +383,9 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
 		/* we have a new avp */
 		if (*nr<max_nr) {
 			/* parse the line key|op|val */
-			c = line.s;
+			c = (unsigned char*)line.s;
 			/* parse the key name */
-			for( key.s=c ; *c && (isalnum((int)*c)||*c=='_') ; c++ );
+			for( key.s=(char*)c ; *c && (isalnum((int)*c)||*c=='_') ; c++ );
 			if (!*c) goto parse_error;
 			key.len = (char*)c-key.s;
 			if (key.len==0) goto parse_error;
@@ -393,7 +393,7 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
 			for( sp_found=0 ; *c && isspace((int)*c) ; c++,sp_found=1 );
 			if (!*c) goto parse_error;
 			/* parse the operator */
-			op.s = c;
+			op.s = (char*)c;
 			switch (*c) {
 				case '<':
 				case '>':
@@ -417,24 +417,24 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
 			for( ; *c && isspace((int)*c) ; c++ );
 			if (!*c) goto parse_error;
 			/* get value */
-			val.s = c;
+			val.s = (char*)c;
 			val.len = line.len - ((char*)c-line.s);
 			if (val.len==0) goto parse_error;
 			if (parse_db_value( &val, &vals[*nr], &p_val)!=0)
 				goto error;
 			/* duplicate the avp -> make all null terminated */
-			c = (char*)pkg_malloc(key.len+op.len+2+(p_val?p_val->len+1:0));
+			c = pkg_malloc(key.len+op.len+2+(p_val?p_val->len+1:0));
 			if (c==0) {
 				semidouble_log("no more pkg memory");
 				goto error;
 			}
 			/*copy the key */
-			keys[*nr] = c;
+			keys[*nr] = (char*)c;
 			memcpy( c, key.s, key.len);
 			c[key.len] = 0;
 			c += key.len + 1;
 			/*copy the op */
-			ops[*nr] = c;
+			ops[*nr] = (char*)c;
 			memcpy( c, op.s, op.len);
 			c[op.len] = 0;
 			c += op.len + 1;
@@ -442,7 +442,7 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
 			if (p_val) {
 				memcpy( c, p_val->s, p_val->len);
 				c[p_val->len] = 0;
-				p_val->s = c;
+				p_val->s = (char*)c;
 			}
 			/* done */
 			(*nr)++;

+ 2 - 1
dset.c

@@ -186,7 +186,8 @@ int append_branch(struct sip_msg* msg, char* uri, int uri_len, char* dst_uri, in
  */
 char* print_dset(struct sip_msg* msg, int* len) 
 {
-	int cnt, i, qlen;
+	int cnt, i;
+	unsigned int qlen;
 	qvalue_t q;
 	str uri;
 	char* p, *qbuf;

+ 2 - 2
main.c

@@ -757,7 +757,7 @@ static int parse_phostport(char* s, char** host, int* hlen, int* port,
 		return 0;
 	}
 	if (second){ /* 2 ':' found => check if valid */
-		if (parse_proto(s, first-s, proto)<0) goto error_proto;
+		if (parse_proto((unsigned char*)s, first-s, proto)<0) goto error_proto;
 		*port=strtol(second+1, &tmp, 10);
 		if ((tmp==0)||(*tmp)||(tmp==second+1)) goto error_port;
 		*host=first+1;
@@ -768,7 +768,7 @@ static int parse_phostport(char* s, char** host, int* hlen, int* port,
 	*port=strtol(first+1, &tmp, 10);
 	if ((tmp==0)||(*tmp)||(tmp==first+1)){
 		/* invalid port => it's proto:host */
-		if (parse_proto(s, first-s, proto)<0) goto error_proto;
+		if (parse_proto((unsigned char*)s, first-s, proto)<0) goto error_proto;
 		*port=0;
 		*host=first+1;
 		*hlen=(int)(p-*host);

+ 1 - 2
modparam.c

@@ -115,8 +115,7 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
 						name, t->exports->name, t->path);
 
 					if (param->type&USE_FUNC_PARAM) {
-						n = ((param_func_t)(param->param_pointer))
-							(type, (param_func_param_t)(char*)val );
+						n = ((param_func_t)(param->param_pointer))(type, val );
 						if (n<0)
 							return -4;
 					} else {

+ 10 - 9
modules/tm/t_fifo.c

@@ -182,7 +182,7 @@ static void print_tw_append( struct tw_append *append)
  * tw_append = name:element[;element]
  * element   = [title=]value 
  * value     = avp[avp_spec] | hdr[hdr_name] | msg[body] */
-int parse_tw_append( modparam_t type, param_func_param_t param_val)
+int parse_tw_append( modparam_t type, void* val)
 {
 	struct hdr_field hdr;
 	struct hdr_avp *last;
@@ -194,9 +194,9 @@ int parse_tw_append( modparam_t type, param_func_param_t param_val)
 	str foo;
 	int n;
 	
-	if (param_val.string==0 || param_val.string[0]==0)
+	if (val==0 || ((char*)val)[0]==0)
 		return 0;
-	s = param_val.string;
+	s = (char*)val;
 
 	/* start parsing - first the name */
 	while( *s && isspace((int)*s) )  s++;
@@ -405,11 +405,11 @@ int parse_tw_append( modparam_t type, param_func_param_t param_val)
 
 	print_tw_append( app );
 	/* free the old string */
-	pkg_free( param_val.string );
+	pkg_free(val);
 	return 0;
 parse_error:
 	LOG(L_ERR,"ERROR:tm:parse_tw_append: parse error in <%s> around "
-		"position %ld\n", param_val.string, (long)(s-param_val.string));
+		"position %ld\n", (char*)val, (long)(s-(char*)val));
 error:
 	return -1;
 }
@@ -580,6 +580,7 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
 	struct hdr_field *hdr;
 	struct usr_avp   *avp;
 	int_str          avp_val;
+	int_str          avp_name;
 	char  *end;
 	str   foo;
 	int   msg_parsed;
@@ -591,11 +592,11 @@ static inline char* append2buf( char *buf, int len, struct sip_msg *req,
 		if (ha->type==ELEM_IS_AVP) {
 			/* search for the AVP */
 			if (ha->sval.s) {
-				avp = search_first_avp( AVP_NAME_STR, (int_str)&ha->sval,
-					&avp_val);
+				avp_name.s=&ha->sval;
+				avp = search_first_avp( AVP_NAME_STR, avp_name, &avp_val);
 			} else {
-				avp = search_first_avp( 0, (int_str)ha->ival,
-					&avp_val);
+				avp_name.n=ha->ival;
+				avp = search_first_avp( 0, avp_name, &avp_val);
 			}
 			if (avp) {
 				if (avp->flags&AVP_VAL_STR) {

+ 1 - 1
modules/tm/t_fifo.h

@@ -42,7 +42,7 @@ extern int tm_unix_tx_timeout;
 
 int fixup_t_write( void** param, int param_no);
 
-int parse_tw_append( modparam_t type, param_func_param_t param_val);
+int parse_tw_append( modparam_t type, void* val);
 
 int init_twrite_lines();
 

+ 1 - 1
modules/tm/t_funcs.c

@@ -347,7 +347,7 @@ void init_avp_params(void)
 /*
  * Get the FR_{INV}_TIMER from corresponding AVP
  */
-int avp2timer(int* timer, int_str param)
+int avp2timer(unsigned int* timer, int_str param)
 {
 	struct usr_avp *avp;
 	int_str val_istr;

+ 2 - 2
modules/tm/t_funcs.h

@@ -115,12 +115,12 @@ int send_pr_buffer( struct retr_buf *rb, void *buf, int len);
 /*
  * Get the FR_{INV}_TIMER from corresponding AVP
  */
-int avp2timer(int* timer, int_str param);
+int avp2timer(unsigned int* timer, int_str param);
 
 
 static void inline _set_fr_retr( struct retr_buf *rb, int retr )
 {
-	int timer;
+	unsigned int timer;
 
 	if (retr) {
 		rb->retr_list=RT_T1_TO_1;

+ 1 - 1
modules/tm/t_hooks.c

@@ -84,7 +84,7 @@ void destroy_tmcb_lists()
 }
 
 
-inline int insert_tmcb(struct tmcb_head_list *cb_list, int types,
+static inline int insert_tmcb(struct tmcb_head_list *cb_list, int types,
 									transaction_cb f, void *param )
 {
 	struct tm_callback *cbp;

+ 1 - 1
modules/tm/t_reply.c

@@ -1208,7 +1208,7 @@ int reply_received( struct sip_msg  *p_msg )
 	struct cell *t;
 	str next_hop;
 	struct usr_avp **backup_list;
-	int timer;
+	unsigned int timer;
 
 	/* make sure we know the associated transaction ... */
 	if (t_check( p_msg  , &branch )==-1)

+ 7 - 10
sr_module.h

@@ -36,6 +36,8 @@
  *  2004-03-12  extra flag USE_FUNC_PARAM added to modparam type -
  *              instead of copying the param value, a func is called (bogdan)
  *  2004-09-19  switched to version.h for the module versions checks (andrei)
+ *  2004-12-03  changed param_func_t to (modparam_t, void*), killed
+ *               param_func_param_t   (andrei)
  */
 
 
@@ -55,19 +57,14 @@ typedef int (*init_function)(void);
 typedef int (*child_init_function)(int rank);
 
 
-#define STR_PARAM        (1<<0)  /* String parameter type */
-#define INT_PARAM        (1<<1)  /* Integer parameter type */
-#define USE_FUNC_PARAM   (1<<(8*sizeof(int)-1))
+#define STR_PARAM        (1U<<0)  /* String parameter type */
+#define INT_PARAM        (1U<<1)  /* Integer parameter type */
+#define USE_FUNC_PARAM   (1U<<(8*sizeof(int)-1))
 #define PARAM_TYPE_MASK(_x)   ((_x)&(~USE_FUNC_PARAM))
 
-typedef int modparam_t;
+typedef unsigned int modparam_t;
 
-typedef union {
-	int integer;
-	char *string;
-} param_func_param_t;
-
-typedef int (*param_func_t)( modparam_t type, param_func_param_t param_val);
+typedef int (*param_func_t)( modparam_t type, void* val);
 
 #define REQUEST_ROUTE 1  /* Function can be used in request route blocks */
 #define FAILURE_ROUTE 2  /* Function can be used in reply route blocks */

+ 1 - 1
unixsock_server.c

@@ -82,7 +82,7 @@ static struct unixsock_cmd* cmd_list = 0;
 static char reply_buf[UNIXSOCK_BUF_SIZE];
 static str reply_pos;
 static struct sockaddr_un reply_addr;
-static int reply_addr_len;
+static unsigned int reply_addr_len;
 
 static time_t up_since;
 static char up_since_ctime[MAX_CTIME_LEN];