From d1cd2764563dabb1e71cfce88b553f79fd16e76d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 2 Dec 2007 10:55:56 +0100 Subject: [PATCH] [CLEANUP] remove a warning from gcc due to htons() in standard.c 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/standard.c b/src/standard.c index d245949a9..0b1629659 100644 --- a/src/standard.c +++ b/src/standard.c @@ -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; }