]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: server: fix build warnings introduced by load-server-state
authorWilly Tarreau <w@1wt.eu>
Tue, 29 Sep 2015 16:32:57 +0000 (18:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 29 Sep 2015 16:32:57 +0000 (18:32 +0200)
Commit e11cfcd ("MINOR: config: new backend directives:
load-server-state-from-file and server-state-file-name") caused these
warnings when building with Clang :

src/server.c:1972:21: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                            (srv_uweight < 0) || (srv_uweight > SRV_UWGHT_MAX))
                             ~~~~~~~~~~~ ^ ~
src/server.c:1980:21: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                            (srv_iweight < 0) || (srv_iweight > SRV_UWGHT_MAX))
                             ~~~~~~~~~~~ ^ ~

Indeed, srv_iweight and srv_uweight are unsigned. Just drop the offending test.

src/server.c

index bc92c3cb0f324921ffb8113552e73b0d928b3b75..c97c5bf8721c6d8492e7f1abef5af394cd16f607 100644 (file)
@@ -1968,16 +1968,14 @@ static void srv_update_state(struct server *srv, int version, char **params)
                        p = NULL;
                        errno = 0;
                        srv_uweight = strtol(params[3], &p, 10);
-                       if ((p == params[3]) || errno == EINVAL || errno == ERANGE ||
-                           (srv_uweight < 0) || (srv_uweight > SRV_UWGHT_MAX))
+                       if ((p == params[3]) || errno == EINVAL || errno == ERANGE || (srv_uweight > SRV_UWGHT_MAX))
                                chunk_appendf(msg, ", invalid srv_uweight value '%s'", params[3]);
 
                        /* validating srv_iweight */
                        p = NULL;
                        errno = 0;
                        srv_iweight = strtol(params[4], &p, 10);
-                       if ((p == params[4]) || errno == EINVAL || errno == ERANGE ||
-                           (srv_iweight < 0) || (srv_iweight > SRV_UWGHT_MAX))
+                       if ((p == params[4]) || errno == EINVAL || errno == ERANGE || (srv_iweight > SRV_UWGHT_MAX))
                                chunk_appendf(msg, ", invalid srv_iweight value '%s'", params[4]);
 
                        /* validating srv_last_time_change */