Skip to content

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

Merged
merged 1 commit into from
Nov 9, 2017
Merged

Conversation

kegilbert
Copy link
Contributor

@kegilbert kegilbert commented Oct 13, 2017

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).

@theotherjimmy
Copy link
Contributor

@kegilbert Why are these warnings only in the online compiler and exporters and not by the build system. Is there a deficiency somewhere?

@kegilbert kegilbert changed the title Remove build warnings from online compiler and exported projects in LWIP Remove build warnings in LWIP Oct 16, 2017
@kegilbert
Copy link
Contributor Author

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) {
Copy link
Contributor

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

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 17, 2017

cc @kjbracey-arm

@kegilbert kegilbert force-pushed the fix-build-warnings branch 2 times, most recently from 9aec598 to 4d858ee Compare October 17, 2017 16:04
@kjbracey
Copy link
Contributor

CC @mikaleppanen

@@ -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();
Copy link
Contributor

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

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"

Copy link
Contributor Author

@kegilbert kegilbert Oct 18, 2017

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.

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.

Copy link
Contributor

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...

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.

@kegilbert
Copy link
Contributor Author

Error case now returned NSAPI_ERROR_NO_CONNECTION rather than the converted error code from ppp_lwip_disconnect()

@kjbracey
Copy link
Contributor

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.

@kjbracey
Copy link
Contributor

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 (void) in front of it, I guess?

@adbridge
Copy link
Contributor

@kegilbert Can you address Kevin's comments please

@kegilbert
Copy link
Contributor Author

Sorry the delay, updated the PR @kjbracey-arm

@adbridge
Copy link
Contributor

@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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@theotherjimmy
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 2, 2017

@studavekar
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 6, 2017

Build : SUCCESS

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

Triggering tests

/morph test
/morph uvisor-test

@mbed-ci
Copy link

mbed-ci commented Nov 6, 2017

@studavekar
Copy link
Contributor

/morph test

@mbed-ci
Copy link

mbed-ci commented Nov 7, 2017

@mbed-ci
Copy link

mbed-ci commented Nov 8, 2017

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.

8 participants