[FFmpeg-cvslog] avserver: fix constness casting warnings

Janne Grunau git at videolan.org
Fri Nov 16 13:36:40 CET 2012


ffmpeg | branch: master | Janne Grunau <janne-libav at jannau.net> | Thu Oct 25 15:55:05 2012 +0200| [39c4afd926944a716c3b11b321cea7f7c798e9e7] | committer: Janne Grunau

avserver: fix constness casting warnings

Use a different char* for extracting info string from the URL. The
other pointer can be made const then which elimates the need for a
cast and fixes the following warnings:
warning: to be safe all intermediate pointers in cast from ‘char **’ to
‘const char **’ must be ‘const’ qualified [-Wcast-qual]

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39c4afd926944a716c3b11b321cea7f7c798e9e7
---

 avserver.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/avserver.c b/avserver.c
index 9f6b9d9..7b38c23 100644
--- a/avserver.c
+++ b/avserver.c
@@ -1478,7 +1478,8 @@ enum RedirType {
 /* parse http request and prepare header */
 static int http_parse_request(HTTPContext *c)
 {
-    char *p;
+    const char *p;
+    char *p1;
     enum RedirType redir_type;
     char cmd[32];
     char info[1024], filename[1024];
@@ -1489,10 +1490,10 @@ static int http_parse_request(HTTPContext *c)
     FFStream *stream;
     int i;
     char ratebuf[32];
-    char *useragent = 0;
+    const char *useragent = 0;
 
     p = c->buffer;
-    get_word(cmd, sizeof(cmd), (const char **)&p);
+    get_word(cmd, sizeof(cmd), &p);
     av_strlcpy(c->method, cmd, sizeof(c->method));
 
     if (!strcmp(cmd, "GET"))
@@ -1502,7 +1503,7 @@ static int http_parse_request(HTTPContext *c)
     else
         return -1;
 
-    get_word(url, sizeof(url), (const char **)&p);
+    get_word(url, sizeof(url), &p);
     av_strlcpy(c->url, url, sizeof(c->url));
 
     get_word(protocol, sizeof(protocol), (const char **)&p);
@@ -1515,10 +1516,10 @@ static int http_parse_request(HTTPContext *c)
         http_log("%s - - New connection: %s %s\n", inet_ntoa(c->from_addr.sin_addr), cmd, url);
 
     /* find the filename and the optional info string in the request */
-    p = strchr(url, '?');
-    if (p) {
-        av_strlcpy(info, p, sizeof(info));
-        *p = '\0';
+    p1 = strchr(url, '?');
+    if (p1) {
+        av_strlcpy(info, p1, sizeof(info));
+        *p1 = '\0';
     } else
         info[0] = '\0';
 
@@ -1635,7 +1636,7 @@ static int http_parse_request(HTTPContext *c)
     }
 
     if (redir_type != REDIR_NONE) {
-        char *hostinfo = 0;
+        const char *hostinfo = 0;
 
         for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {
             if (av_strncasecmp(p, "Host:", 5) == 0) {
@@ -1764,7 +1765,7 @@ static int http_parse_request(HTTPContext *c)
         if (!stream->is_feed) {
             /* However it might be a status report from WMP! Let us log the
              * data as it might come in handy one day. */
-            char *logline = 0;
+            const char *logline = 0;
             int client_id = 0;
 
             for (p = c->buffer; *p && *p != '\r' && *p != '\n'; ) {



More information about the ffmpeg-cvslog mailing list