]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: peers: fix format string for status messages (int signedness)
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Nov 2022 14:32:20 +0000 (15:32 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Nov 2022 14:32:20 +0000 (15:32 +0100)
In issue #1939, Ilya mentions that cppchecks warned about use of "%d" to
report the status state that's locally stored as an unsigned int. While
technically valid, this will never cause any trouble since in the end
what we store there are the applet's states (just a few enum values).
Better use %u anyway to silence this warning.

src/peers.c

index 95b4b9f1618d722ab0e7c62838bb7eac4d85dc73..fcfa05d71ac4771a065506e91f006458b4fdecc6 100644 (file)
@@ -616,7 +616,7 @@ static int peer_prepare_status_errormsg(char *msg, size_t size, struct peer_prep
        unsigned int st1;
 
        st1 = p->error_status.st1;
-       ret = snprintf(msg, size, "%d\n", st1);
+       ret = snprintf(msg, size, "%u\n", st1);
        if (ret >= size)
                return 0;