]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: standard: Use len2mask4 in str2mask
authorTim Duesterhus <tim@bastelstu.be>
Thu, 25 Jan 2018 15:24:48 +0000 (16:24 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Jan 2018 21:25:40 +0000 (22:25 +0100)
The len2mask4 function was introduced in commit:
70473a5f8c56d8ec2e837b9b66443dc252b24da9
which is about six years later than the commit that introduced the
str2mask function:
2937c0dd20f2f3c0065b671bbfe3fafcd8862eaf

This is a clean up in preparation for a str2mask6 function which
will use len2mask6.

src/standard.c

index acd136c27c384c256fde7dc7d15a2607d4cd1b56..495bae571c1b7e605e907f677fedcf29d8fe1cd3 100644 (file)
@@ -1022,10 +1022,8 @@ int str2mask(const char *str, struct in_addr *mask)
 
                if (!*str || (err && *err) || (unsigned)len > 32)
                        return 0;
-               if (len)
-                       mask->s_addr = htonl(~0UL << (32 - len));
-               else
-                       mask->s_addr = 0;
+
+               len2mask4(len, mask);
        }
        return 1;
 }