From: Daniel Lezcano Date: Mon, 14 Feb 2011 08:22:08 +0000 (+0100) Subject: Simplify broadcast computation X-Git-Tag: lxc-0.7.4~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b7d474304236d6b593dd15833e505e35590dba0;p=thirdparty%2Flxc.git Simplify broadcast computation David Ward reported this computation could be written in a simpler way. Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 7c7275238..1d30cba08 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -423,8 +423,9 @@ static int config_network_ipv4(const char *key, char *value, * prefix and address */ if (!bcast) { - int mask = htonl(INADDR_BROADCAST << (32 - inetdev->prefix)); - inetdev->bcast.s_addr = (inetdev->addr.s_addr & mask) | ~mask; + inetdev->bcast.s_addr = inetdev->addr.s_addr; + inetdev->bcast.s_addr |= + htonl(INADDR_BROADCAST >> inetdev->prefix); } lxc_list_add(&netdev->ipv4, list);