Skip to content

Conversation

@pauluap
Copy link

@pauluap pauluap commented Apr 11, 2018

Description

In file included from .././features/FEATURE_LWIP/lwip-interface/lwip/src/include/lwip/ip_addr.h:43:0,
                 from .././features/FEATURE_LWIP/lwip-interface/lwip/src/include/lwip/netif.h:46,
                 from ../features/FEATURE_LWIP/lwip-interface/lwip_stack.h:23,
                 from ../features/FEATURE_LWIP/lwip-interface/lwip_stack.c:23:
../features/FEATURE_LWIP/lwip-interface/lwip_stack.c: In function 'mbed_lwip_socket_bind':
.././features/FEATURE_LWIP/lwip-interface/lwip/src/include/lwip/ip4_addr.h:171:40: warning: the comparison will always evaluate as 'false' for the address of 'ip_addr' will never be NULL [-Waddress]
 #define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1)))
                                        ^
.././features/FEATURE_LWIP/lwip-interface/lwip/src/include/lwip/ip_addr.h:272:49: note: in expansion of macro 'ip4_addr_isany'
 #define ip_addr_isany(ipaddr)                   ip4_addr_isany(ipaddr)
                                                 ^~~~~~~~~~~~~~
../features/FEATURE_LWIP/lwip-interface/lwip_stack.c:1138:10: note: in expansion of macro 'ip_addr_isany'
     if (!ip_addr_isany(&ip_addr) && !mbed_lwip_is_local_addr(&ip_addr)) {
          ^~~~~~~~~~~~~

Because the function ip_addr_isany() is actually a macro, it ends up being expanded in place with a constant boolean result.

My solution is a dirty trick, providing a pointer variable alias. My thought that is the ideal solution would use a function rather than a macro, but there's probably other considerations

Pull request type

[X] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

@pauluap pauluap force-pushed the compiler_warning_macro_expansion_constant_boolean branch from 460a760 to 090647e Compare April 12, 2018 16:51
@pauluap pauluap changed the base branch from mbed-os-5.8 to master April 12, 2018 16:54
@0xc0170 0xc0170 requested a review from kjbracey April 13, 2018 10:56
@kjbracey
Copy link
Contributor

I think the correct and optimised fix is to use ipaddr_is_any_val(ip_addr). Can you try that?

@pauluap
Copy link
Author

pauluap commented Apr 13, 2018

Yes, replacing with ip_addr_isany_val is still successful in suppression of the compiler warnings

Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, but please squash to one commit and get rid of all the unconnected formatting changes. We've got a big merge coming in from feature-emac, and I want to minimise conflicting changes to these areas.

@pauluap pauluap force-pushed the compiler_warning_macro_expansion_constant_boolean branch from 9b15996 to 8e76150 Compare April 13, 2018 12:09
@pauluap
Copy link
Author

pauluap commented Apr 13, 2018

Cool. Done.

@cmonr
Copy link
Contributor

cmonr commented Apr 13, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Apr 13, 2018

Build : SUCCESS

Build number : 1748
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6613/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Apr 14, 2018

@mbed-ci
Copy link

mbed-ci commented Apr 14, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Apr 16, 2018

/morph mbed2-build

@cmonr cmonr merged commit c867934 into ARMmbed:master Apr 16, 2018
@pauluap pauluap deleted the compiler_warning_macro_expansion_constant_boolean branch April 16, 2018 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants