From d0f2f4f00413e851fe2c0df8165f1bc5ab09ef0a Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Tue, 26 Oct 2021 16:11:25 +0800 Subject: [PATCH] Revert "Use an unnamed variable instead of a named one" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes failures in the test suite when building in C++ mode. This reverts commit fa4e7e92260e33f78b72e7796b3df28c4c84b8e2. In file included from header_checker.cpp:6: ../include/usbg/function/net.h: In function ‘int usbg_f_net_get_dev_addr(usbg_f_net*, ether_addr*)’: ../include/usbg/usbg.h:61:16: error: taking address of rvalue [-fpermissive] 61 | ((union UNAME){ .FIELD = WHAT, }) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ ../include/usbg/function/net.h:51:2: note: in expansion of macro ‘USBG_TO_UNION’ 51 | USBG_TO_UNION(usbg_f_net_attr_val, dev_addr, WHAT) | ^~~~~~~~~~~~~ ../include/usbg/function/net.h:131:12: note: in expansion of macro ‘USBG_F_NET_ETHER_ADDR_TO_ATTR_VAL’ 131 | &USBG_F_NET_ETHER_ADDR_TO_ATTR_VAL(*addr)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/usbg/function/net.h: In function ‘int usbg_f_net_get_host_addr(usbg_f_net*, ether_addr*)’: ../include/usbg/usbg.h:61:16: error: taking address of rvalue [-fpermissive] 61 | ((union UNAME){ .FIELD = WHAT, }) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ ../include/usbg/function/net.h:51:2: note: in expansion of macro ‘USBG_TO_UNION’ 51 | USBG_TO_UNION(usbg_f_net_attr_val, dev_addr, WHAT) | ^~~~~~~~~~~~~ ../include/usbg/function/net.h:157:12: note: in expansion of macro ‘USBG_F_NET_ETHER_ADDR_TO_ATTR_VAL’ 157 | &USBG_F_NET_ETHER_ADDR_TO_ATTR_VAL(*addr)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- include/usbg/function/net.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/usbg/function/net.h b/include/usbg/function/net.h index fa2fcba..3be5a94 100644 --- a/include/usbg/function/net.h +++ b/include/usbg/function/net.h @@ -127,8 +127,8 @@ int usbg_f_net_set_attr_val(usbg_f_net *nf, enum usbg_f_net_attr attr, static inline int usbg_f_net_get_dev_addr(usbg_f_net *nf, struct ether_addr *addr) { - return usbg_f_net_get_attr_val(nf, USBG_F_NET_DEV_ADDR, - &USBG_F_NET_ETHER_ADDR_TO_ATTR_VAL(*addr)); + union usbg_f_net_attr_val val = { .dev_addr = *addr, }; + return usbg_f_net_get_attr_val(nf, USBG_F_NET_DEV_ADDR, &val); } /** @@ -153,8 +153,8 @@ static inline int usbg_f_net_set_dev_addr(usbg_f_net *nf, static inline int usbg_f_net_get_host_addr(usbg_f_net *nf, struct ether_addr *addr) { - return usbg_f_net_get_attr_val(nf, USBG_F_NET_HOST_ADDR, - &USBG_F_NET_ETHER_ADDR_TO_ATTR_VAL(*addr)); + union usbg_f_net_attr_val val = { .host_addr = *addr, }; + return usbg_f_net_get_attr_val(nf, USBG_F_NET_HOST_ADDR, &val); } /**