lib:socket: Return early if we have only one interface
authorAndreas Schneider <asn@samba.org>
Thu, 7 Dec 2017 14:54:13 +0000 (15:54 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 20 Mar 2018 22:16:16 +0000 (23:16 +0100)
This fixes compilation with -Wstrict-overflow=2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/socket/interfaces.c

index 6409275d7bcf86057974de558c4dedea6efd29ca..168bff501c213b98aa89f462144d36d36286cfca 100644 (file)
@@ -367,7 +367,10 @@ int get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
        int total, i, j;
 
        total = _get_interfaces(mem_ctx, &ifaces);
-       if (total <= 0) return total;
+       /* If we have an error, no interface or just one we can leave */
+       if (total <= 1) {
+               return total;
+       }
 
        /* now we need to remove duplicates */
        TYPESAFE_QSORT(ifaces, total, iface_comp);