From: Jo-Philipp Wich Date: Mon, 6 Feb 2023 14:46:49 +0000 (+0100) Subject: rpcd-mod-luci: fix reporting network device flags X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=a570e300061fae7250999c35e4e7215940bca82d;p=project%2Fluci.git rpcd-mod-luci: fix reporting network device flags Fix reporting of ceertain flag values larger than 255, such as IFF_PROMISC by explicitly casting the bit test expression to a boolean result since the implicit integer truncation to uint8_t will turn the `0x100` result of a set IFF_PROMISC bit into just `0x0`. Signed-off-by: Jo-Philipp Wich --- diff --git a/libs/rpcd-mod-luci/src/luci.c b/libs/rpcd-mod-luci/src/luci.c index 4bef961c35..7dd3ef27c7 100644 --- a/libs/rpcd-mod-luci/src/luci.c +++ b/libs/rpcd-mod-luci/src/luci.c @@ -788,13 +788,13 @@ rpc_luci_parse_network_device_sys(const char *name, struct ifaddrs *ifaddr) blobmsg_close_table(&blob, o2); o2 = blobmsg_open_table(&blob, "flags"); - blobmsg_add_u8(&blob, "up", ifa_flags & IFF_UP); - blobmsg_add_u8(&blob, "broadcast", ifa_flags & IFF_BROADCAST); - blobmsg_add_u8(&blob, "promisc", ifa_flags & IFF_PROMISC); - blobmsg_add_u8(&blob, "loopback", ifa_flags & IFF_LOOPBACK); - blobmsg_add_u8(&blob, "noarp", ifa_flags & IFF_NOARP); - blobmsg_add_u8(&blob, "multicast", ifa_flags & IFF_MULTICAST); - blobmsg_add_u8(&blob, "pointtopoint", ifa_flags & IFF_POINTOPOINT); + blobmsg_add_u8(&blob, "up", !!(ifa_flags & IFF_UP)); + blobmsg_add_u8(&blob, "broadcast", !!(ifa_flags & IFF_BROADCAST)); + blobmsg_add_u8(&blob, "promisc", !!(ifa_flags & IFF_PROMISC)); + blobmsg_add_u8(&blob, "loopback", !!(ifa_flags & IFF_LOOPBACK)); + blobmsg_add_u8(&blob, "noarp", !!(ifa_flags & IFF_NOARP)); + blobmsg_add_u8(&blob, "multicast", !!(ifa_flags & IFF_MULTICAST)); + blobmsg_add_u8(&blob, "pointtopoint", !!(ifa_flags & IFF_POINTOPOINT)); blobmsg_close_table(&blob, o2); o2 = blobmsg_open_table(&blob, "link");