]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: conn: Do not pass a pointer to likely
authorTim Duesterhus <tim@bastelstu.be>
Fri, 21 Feb 2020 12:02:03 +0000 (13:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 06:30:49 +0000 (07:30 +0100)
Move the `!` inside the likely and negate it to unlikely.

The previous version should not have caused issues, because it is converted
to a boolean / integral value before being passed to __builtin_expect(), but
it's certainly unusual.

[wt: this was not a bug but purposely written like this to improve code
 generation on older compilers but not needed anymore as described here:
 https://www.mail-archive.com/haproxy@formilux.org/msg36392.html ]

include/proto/connection.h

index c7caeea2b16ff0ff31a9a50673e5c0c209a1b7a0..fb264d2b59d60d797a65dce6069c95cbe835e386 100644 (file)
@@ -400,12 +400,12 @@ static inline struct conn_stream *cs_new(struct connection *conn)
        struct conn_stream *cs;
 
        cs = pool_alloc(pool_head_connstream);
-       if (!likely(cs))
+       if (unlikely(!cs))
                return NULL;
 
        if (!conn) {
                conn = conn_new();
-               if (!likely(conn)) {
+               if (unlikely(!conn)) {
                        cs_free(cs);
                        return NULL;
                }