]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: dns: Use DISGUISE() on a never-failing ring_attach() call
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 4 Mar 2021 15:53:27 +0000 (16:53 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 4 Mar 2021 15:53:28 +0000 (16:53 +0100)
When a DNS session is created, the call to ring_attach() never fails. The
ring is freshly initialized and there is other watcher on it. Thus, the call
always succeeds.

Instead of catching an error that must never happen, we use the DISGUISE()
macro to make static analyzers happy.

src/dns.c

index dcdc163100ec22ed7ea1e05314f4050584b88d8f..d360f2cdcfd33400f8708f2636f90d090ca27a30 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -1028,13 +1028,8 @@ struct dns_session *dns_session_new(struct dns_stream_server *dss)
                goto error;
 
        ring_init(&ds->ring, ds->tx_ring_area, DNS_TCP_MSG_RING_MAX_SIZE);
-       if (!ring_attach(&ds->ring)) {
-               /* Should never happen
-                * since we are the first attached
-                * here
-                */
-               goto error;
-       }
+       /* never fail because it is the first watcher attached to the ring */
+       DISGUISE(ring_attach(&ds->ring));
 
        if ((ds->task_exp = task_new(tid_bit)) == NULL)
                goto error;