URL-Parser: as pointed out by Bernds scan-build, we don't use the pointers we put...
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 19 Jul 2012 11:03:34 +0000 (13:03 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Thu, 19 Jul 2012 11:03:34 +0000 (13:03 +0200)
  - limit the scope from pEndHost so its usage is more clear

libcitadel/lib/urlhandling.c

index 41d38324a30ce2ae30d18d79c5a965c37f2866ae..8896770eea84ce4755eaf3aad5864d78b070091f 100644 (file)
@@ -44,7 +44,7 @@ void FreeURL(ParsedURL** Url)
  */
 int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
 {
-       const char *pch, *pEndHost, *pPort, *pCredEnd, *pUserEnd;
+       const char *pch, *pPort, *pCredEnd, *pUserEnd;
        ParsedURL *url = (ParsedURL *)malloc(sizeof(ParsedURL));
        memset(url, 0, sizeof(ParsedURL));
 
@@ -55,12 +55,12 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
         */
        url->URL = NewStrBufDup(UrlStr);
        url->Host = pch = ChrPtr(url->URL);
-       pEndHost = url->LocalPart = strchr(pch, '/');
+       url->LocalPart = strchr(pch, '/');
        if (url->LocalPart != NULL) {
                if ((*(url->LocalPart + 1) == '/') && 
                    (*(url->LocalPart - 1) == ':')) { /* TODO: find default port for this protocol... */
                        url->Host = url->LocalPart + 2;
-                       pEndHost = url->LocalPart = strchr(url->Host, '/');
+                       url->LocalPart = strchr(url->Host, '/');
                        if (url->LocalPart != NULL)
                        {
                            StrBufPeek(url->URL, url->LocalPart, 0, '\0');
@@ -69,7 +69,7 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
                }
        }
        if (url->LocalPart == NULL) {
-               pEndHost = url->LocalPart = ChrPtr(url->URL) + StrLength(url->URL);
+               url->LocalPart = ChrPtr(url->URL) + StrLength(url->URL);
        }
 
        pCredEnd = strrchr(ChrPtr(url->URL), '@');
@@ -94,6 +94,7 @@ int ParseURL(ParsedURL **Url, StrBuf *UrlStr, unsigned short DefaultPort)
        
        pPort = NULL;
        if (*url->Host == '[') {
+               const char *pEndHost;
                url->Host ++;
                pEndHost = strchr(url->Host, ']');
                if (pEndHost == NULL) {