Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tap_manager: work around flexible array members in uapi
Recently the kernel replaced depracted zero-length arrays with flexible arrays [1]. Unfortunately this causes the compilation to fail, since now G++ rejects anything in structs behind the flexible array member: Feb 16 11:42:33 | In file included from ../git/src/netlink/tap_manager.cc:11: Feb 16 11:42:33 | /tmp/generic-x86-64/work/corei7-64-poky-linux/baseboxd/2.1.0-r0/recipe-sysroot/usr/include/linux/ethtool.h: In member function 'virtual int basebox::tap_manager::set_port_speed(std::string, uint32_t, uint8_t)': Feb 16 11:42:33 | /tmp/generic-x86-64/work/corei7-64-poky-linux/baseboxd/2.1.0-r0/recipe-sysroot/usr/include/linux/ethtool.h:2199:17: error: flexible array member 'ethtool_link_settings::link_mode_masks' not at end of 'struct basebox::tap_manager::set_port_speed(std::string, uint32_t, uint8_t)::<unnamed>' Feb 16 11:42:33 | 2199 | __u32 link_mode_masks[]; Feb 16 11:42:33 | | ^~~~~~~~~~~~~~~ Feb 16 11:42:33 | ../git/src/netlink/tap_manager.cc:394:11: note: next member '__u32 basebox::tap_manager::set_port_speed(std::string, uint32_t, uint8_t)::<unnamed struct>::link_mode_data [381]' declared here Feb 16 11:42:33 | 394 | __u32 link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; Feb 16 11:42:33 | | ^~~~~~~~~~~~~~ Feb 16 11:42:33 | ../git/src/netlink/tap_manager.cc:392:10: note: in the definition of 'struct basebox::tap_manager::set_port_speed(std::string, uint32_t, uint8_t)::<unnamed>' Feb 16 11:42:33 | 392 | struct { Feb 16 11:42:33 | | ^ Work around this by switching the order of the elements in our own struct so that the flexible array member is last, but the struct still is sized correctly. Then use a ethtool_link_settings pointer pointing to the beginning of this struct for any further accesses. [1] torvalds/linux@94dfc73 Signed-off-by: Jonas Gorski <[email protected]>
- Loading branch information