-
Notifications
You must be signed in to change notification settings - Fork 3k
Remove build warnings in LWIP #5319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@kegilbert Why are these warnings only in the online compiler and exporters and not by the build system. Is there a deficiency somewhere? |
Spoke offline with @theotherjimmy, warnings were showing up in the short form on local builds, had managed to miss them earlier. Updated title to reflect. |
@@ -658,7 +660,10 @@ nsapi_error_t mbed_lwip_bringup_2(bool dhcp, bool ppp, const char *ip, const cha | |||
if (!netif_is_link_up(&lwip_netif)) { | |||
if (sys_arch_sem_wait(&lwip_netif_linked, 15000) == SYS_ARCH_TIMEOUT) { | |||
if (ppp) { | |||
ppp_lwip_disconnect(); | |||
err_t err = ppp_lwip_disconnect(); | |||
if(err != ERR_OK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ()
- space between as in the rest of this file
cc @kjbracey-arm |
9aec598
to
4d858ee
Compare
@@ -658,7 +660,10 @@ nsapi_error_t mbed_lwip_bringup_2(bool dhcp, bool ppp, const char *ip, const cha | |||
if (!netif_is_link_up(&lwip_netif)) { | |||
if (sys_arch_sem_wait(&lwip_netif_linked, 15000) == SYS_ARCH_TIMEOUT) { | |||
if (ppp) { | |||
ppp_lwip_disconnect(); | |||
err_t err = ppp_lwip_disconnect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this and the similar change below - I think we always want to return NSAPI_ERROR_NO_CONNECTION, not whatever oddities PPP might throw up during attempted shutdown.
@@ -293,7 +293,9 @@ static int get_ip_addr_type(const ip_addr_t *ip_addr) | |||
return IPADDR_TYPE_V4; | |||
} | |||
#endif | |||
#if !LWIP_IPV6 && !LWIP_IPV4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be "#if LWIP_IPV6 && LWIP_IPV4"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in this?
#if LWIP_IPV6 && LWIP_IPV4
return IP_ADDR_ANY;
#if LWIP_IPV4
....
#if LWIP_IPV6
...
I'm honestly not sure what the original intention was, the way it was written seemed to be only return IP_ADDR_ANY if neither LWIP_IPV4 or LWIP_IPV6 was enabled, but the name IP_ADDR_ANY sounds like it should be if both are enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IP_IS_V6/IP_IS_V4 defines do something (other than evaluate to true) only when both LWIP_IPV6 and LWIP_IPV4 flags are enabled. Also disabling both LWIP_IPV6 and LWIP_IPV4 is not valid configuration and will return compilation error. So, the function can reach the return at the end only in dual ipv4v6 configuration.
Currently get_ip_addr_type() function is used by add dns address function and it is not made to be fully general utility function. That is because the dns function calling it never uses it to evaluate address that type is any, and is interested only whether address is either ipv4 or ipv6.
If function would be made more general, there could be also evolution under LWIP_IPV6 && LWIP_IPV4 flags to return IP_ADDR_ANY only in case address type really is any. And to return -1 or some other error, in case address type is not valid at all (field is somehow corrupted).
But I think that since currently this function is used only for purposes of add dns address, adding the above evaluations are not needed and flagging the return with LWIP_IPV6 && LWIP_IPV4 flags is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, I'd be inclined to put a pragma in to shut the compiler up. The ifdefs already in that function are excessive - presumably they're to silence a "constant expression in condition"?
Given the form of the lwIP dual IPv4/v6 code, silencing "unreachable code" and "constant expression" would allow you to just freely use those IS_V4/IS_V6 macros without it getting in the way.
(The Linux kernel is built with those warnings disabled, because there are a lot of similar macros that can either be constant or variable depending on config switches).
In libservice's ns_types.h, you can see NS_DUMMY_DEFINITIONS_OK, which attempts to disable some of them...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using pragma is ok for me. Yes, I agree that it is not very good that we have these IP_IS_V6/IP_IS_V4 etc. defines that would allow to write clear code that works with all configurations, but because of compiler warnings we need to use ifdefs also when using macros and not just when defining them.
4d858ee
to
16cb9e4
Compare
Error case now returned NSAPI_ERROR_NO_CONNECTION rather than the converted error code from ppp_lwip_disconnect() |
Yes, the connection has failed, which is why it's calling ppp_lwip_disconnect() to clean up before returning NO_CONNECTION. I think we want to return NO_CONNECTION, even if the PPP disconnect throws up its own error. |
Oh, I see you've changed it to check the return and literally return "NO_CONNECTION". No, I mean that we don't care what the ppp_disconnect returns. We're already on our way to return NO_CONNECTION or DHCP_FAILURE. If you need to silence a warning or Coverity diagnostic, you could just stick a |
@kegilbert Can you address Kevin's comments please |
16cb9e4
to
ba0fa98
Compare
Sorry the delay, updated the PR @kjbracey-arm |
@kjbracey-arm are you happy with the update ? |
@@ -283,6 +283,9 @@ static void add_dns_addr_to_dns_list_index(const u8_t addr_type, const u8_t inde | |||
|
|||
static int get_ip_addr_type(const ip_addr_t *ip_addr) | |||
{ | |||
#if LWIP_IPV6 && LWIP_IPV4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't correct - if it's going to be done like this, it needs to be at the end - the return remains in the same place, but with the added #if
to shut the compiler up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjbracey-arm Updated in last commit.
ba0fa98
to
5498054
Compare
/morph build |
Build : FAILUREBuild number : 416 |
/morph build |
Build : SUCCESSBuild number : 435 Triggering tests/morph test |
/morph test |
Addresses #5318
Project built in exported projects (tested with make_armc5 in particular) or on the online compiler will generate a good amount of build warnings. These small fixes should resolve the LWIP warnings (and add error checking on ppp_lwip_disconnect calls).