[sr-dev] git:5.3:1797a30e: core: remove compiler warnings [-Wstring-plus-int]

Daniel-Constantin Mierla miconda at gmail.com
Thu Jun 11 21:37:12 CEST 2020


Module: kamailio
Branch: 5.3
Commit: 1797a30ec4a8aebab323a08f832d16d74958b765
URL: https://github.com/kamailio/kamailio/commit/1797a30ec4a8aebab323a08f832d16d74958b765

Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-06-11T21:36:57+02:00

core: remove compiler warnings [-Wstring-plus-int]

> core/parser/parse_fline.c:93:34: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
>               strncasecmp( tmp+1, SIP_VERSION+1, SIP_VERSION_LEN-1)==0 &&
>                                   ~~~~~~~~~~~^~
>
> core/parser/parse_fline.c:121:9: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
>       } else IFISMETHOD( INVITE, 'I' )
>              ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> core/parser/msg_parser.h:131:35: note: expanded from macro 'IFISMETHOD'
>              strncasecmp( tmp+1, #methodname +1, methodname##_LEN-1)==0 &&     \
>                                  ~~~~~~~~~~~~^~

(cherry picked from commit 2b070a622fa3c78d929580fda3c7952963c4066b)

---

Modified: src/core/parser/msg_parser.h
Modified: src/core/parser/parse_fline.c

---

Diff:  https://github.com/kamailio/kamailio/commit/1797a30ec4a8aebab323a08f832d16d74958b765.diff
Patch: https://github.com/kamailio/kamailio/commit/1797a30ec4a8aebab323a08f832d16d74958b765.patch

---

diff --git a/src/core/parser/msg_parser.h b/src/core/parser/msg_parser.h
index 2aad6ecb84..8d242d2832 100644
--- a/src/core/parser/msg_parser.h
+++ b/src/core/parser/msg_parser.h
@@ -128,7 +128,7 @@ typedef enum request_method {
 
 #define IFISMETHOD(methodname,firstchar)                                  \
 if (  (*tmp==(firstchar) || *tmp==((firstchar) | 32)) &&                  \
-		strncasecmp( tmp+1, #methodname +1, methodname##_LEN-1)==0 &&     \
+		strncasecmp( tmp+1, &#methodname[1], methodname##_LEN-1)==0 &&     \
 		*(tmp+methodname##_LEN)==' ') {                                   \
 				fl->type=SIP_REQUEST;                                     \
 				fl->u.request.method.len=methodname##_LEN;                \
diff --git a/src/core/parser/parse_fline.c b/src/core/parser/parse_fline.c
index c535b49a4c..a5aefb7ee8 100644
--- a/src/core/parser/parse_fline.c
+++ b/src/core/parser/parse_fline.c
@@ -90,7 +90,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start* fl)
 	tmp=buffer;
   	/* is it perhaps a reply, ie does it start with "SIP...." ? */
 	if ( 	(*tmp=='S' || *tmp=='s') && 
-		strncasecmp( tmp+1, SIP_VERSION+1, SIP_VERSION_LEN-1)==0 &&
+		strncasecmp( tmp+1, &SIP_VERSION[1], SIP_VERSION_LEN-1)==0 &&
 		(*(tmp+SIP_VERSION_LEN)==' ')) {
 			fl->type=SIP_REPLY;
 			fl->flags|=FLINE_FLAG_PROTO_SIP;
@@ -98,7 +98,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start* fl)
 			tmp=buffer+SIP_VERSION_LEN;
 	} else if (http_reply_parse != 0 && (*tmp=='H' || *tmp=='h')) {
 			/* 'HTTP/1.' */
-			if (strncasecmp( tmp+1, HTTP_VERSION+1, HTTP_VERSION_LEN-1)==0 &&
+			if (strncasecmp( tmp+1, &HTTP_VERSION[1], HTTP_VERSION_LEN-1)==0 &&
 			  /* [0|1] */
 			  ((*(tmp+HTTP_VERSION_LEN)=='0') || (*(tmp+HTTP_VERSION_LEN)=='1')) &&
 			  (*(tmp+HTTP_VERSION_LEN+1)==' ')  ){ 
@@ -111,7 +111,7 @@ char* parse_first_line(char* buffer, unsigned int len, struct msg_start* fl)
 				  fl->u.reply.version.len=HTTP_VERSION_LEN+1 /*include last digit*/;
           tmp=buffer+HTTP_VERSION_LEN+1 /* last digit */;
 			/* 'HTTP/2' */
-			} else if (strncasecmp( tmp+1, HTTP2_VERSION+1, HTTP2_VERSION_LEN-1)==0 &&
+			} else if (strncasecmp( tmp+1, &HTTP2_VERSION[1], HTTP2_VERSION_LEN-1)==0 &&
 						(*(tmp+HTTP2_VERSION_LEN)==' ')) {
 					fl->type=SIP_REPLY;
 					fl->flags|=FLINE_FLAG_PROTO_HTTP;




More information about the sr-dev mailing list