]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CLEANUP] remove a warning from gcc due to htons() in standard.c
authorWilly Tarreau <w@1wt.eu>
Sun, 2 Dec 2007 09:55:56 +0000 (10:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 2 Dec 2007 09:55:56 +0000 (10:55 +0100)
Due to the fact that htons is defined as a macro, it's dangerous
to call it with auto-incremented arguments such as htons(f(++x)) :

src/standard.c: In function 'url2sa':
src/standard.c:291: warning: operation on 'curr' may be undefined

The solution is simply to store the intermediate result an pass it
to htons() at once.

src/standard.c

index d245949a99e5d721e684cc1387e6013e7232a5bd..0b1629659dc083300d3190aff065f2d6f9dcd493 100644 (file)
@@ -288,7 +288,8 @@ int url2sa(const char *url, int ulen, struct sockaddr_in *addr)
                        if (!ret)
                                return -1;
                        curr += ret;
-                       addr->sin_port = (*curr == ':') ? htons(str2uic(++curr)) : htons(80);
+                       addr->sin_port = (*curr == ':') ? str2uic(++curr) : 80;
+                       addr->sin_port = htons(addr->sin_port);
                }
                return 0;
        }