-
Notifications
You must be signed in to change notification settings - Fork 3k
resolve LWIP compiler warning #6780
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
resolve LWIP compiler warning #6780
Conversation
for (idx = 0; idx < dn; idx++) { | ||
/* It is safe to cast dn to uint32 here since it is either derived from the | ||
* uint16 returned by pbuf_clen() above, or it is set to 1. */ | ||
for (idx = 0; idx < (u32_t) dn; idx++) { |
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 we can avoid a cast, would be sweet. In this case the problem is that this unsigned idx
is intended for use elsewhere as the unsigned descriptor index, but this loop is actually comparing with the descriptor count.
No reason to use the same variable. Just have a local s_32_t count
as the loop variable here.
c696a14
to
ba29bd9
Compare
@kjbracey-arm
Done. |
@@ -611,7 +611,7 @@ static err_t lpc_low_level_output(struct netif *netif, struct pbuf *p) | |||
/* Wait until enough descriptors are available for the transfer. */ | |||
/* THIS WILL BLOCK UNTIL THERE ARE ENOUGH DESCRIPTORS AVAILABLE */ | |||
#if NO_SYS == 0 | |||
for (idx = 0; idx < dn; idx++) { | |||
for (count = 0; count < dn; count++) { |
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.
Can you just declare it in here, please.
for (s_32_t count = 0; count < dn; count++)
Minimise variable scopes where possible to make clear they don't have any wider significance.
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.
That is my preferred style, but I was following the style presented here. All local variables are declared at the top of the function.
That said, let me know if you still want me to make that change.
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.
I do like style consistency, but I like reduced-scope variables more. And as it's narrowly scoped, it has very little impact on global style...
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.
Done.
/morph build |
Build : SUCCESSBuild number : 1895 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1542 |
Test : SUCCESSBuild number : 1712 |
/morph mbed2-build |
Description
Cast a variable to resolve a compiler warning.
There is probably a more straight-forward / maintainable way to do it, so feel free to improve on this PR.
Pull request type