ubloxmodem: fix maybe-unitialized error
PATCH 1/1 ubloxmodem: fix maybe-unitialized error
Fixes:
../git/drivers/ubloxmodem/gprs-context.c: In function ‘ublox_gprs_activate_primary’:../git/drivers/ubloxmodem/gprs-context.c:339:2: error: ‘auth’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
snprintf(buf, sizeof(buf), "AT+UAUTHREQ=%u,%u,\"%s\",\"%s\"", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcd->active_context, auth, username, password);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../git/drivers/ubloxmodem/gprs-context.c:324:11: note: ‘auth’ was declared here
unsigned auth;
^~~~
---
drivers/ubloxmodem/gprs-context.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)drivers/ubloxmodem/gprs-context.c +1 -1
@@ -321,7 +321,7 @@ static void ublox_send_uauthreq(struct ofono_gprs_context *gc, {struct gprs_context_data *gcd =ofono_gprs_context_get_data (gc);char buf[UBLOX_MAX_USER_LEN +UBLOX_MAX_PASS_LEN +32 ]; -unsigned auth; +unsigned auth =0 ;switch (auth_method) {case OFONO_GPRS_AUTH_METHOD_PAP :
Signature · 1 line
2.22.0
Hi Martin,
Quoted 10 lines · Martin Hundebøll
Fixes:
../git/drivers/ubloxmodem/gprs-context.c: In function ‘ublox_gprs_activate_primary’:../git/drivers/ubloxmodem/gprs-context.c:339:2: error: ‘auth’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
snprintf(buf, sizeof(buf), "AT+UAUTHREQ=%u,%u,\"%s\",\"%s\"", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~gcd->active_context, auth, username, password); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../git/drivers/ubloxmodem/gprs-context.c:324:11: note: ‘auth’ was declared here
unsigned auth;
What compiler are you using? gcc really needs to make up its mind whether it warns about enums or doesn't. The behavior between versions is nuts.
Quoted 11 lines
^~~~ --- drivers/ubloxmodem/gprs-context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/ubloxmodem/gprs-context.c +0
-0
drivers/ubloxmodem/gprs-context.c static void ublox_send_uauthreq(struct ofono_gprs_context *gc, · line 327
Quoted 8 lines
drivers/ubloxmodem/gprs-context.c +1
-1@@ -321,7 +321,7 @@ static void ublox_send_uauthreq(struct ofono_gprs_context *gc, {struct gprs_context_data *gcd =ofono_gprs_context_get_data (gc);char buf[UBLOX_MAX_USER_LEN +UBLOX_MAX_PASS_LEN +32 ]; -unsigned auth; +unsigned auth =0 ;switch (auth_method) {case OFONO_GPRS_AUTH_METHOD_PAP :
anyhow, applied, thanks.
Regards,
-Denis
Hi Denis,
Quoted 3 lines · Denis Kenzior
What compiler are you using? gcc really needs to make up its mind whether it warns about enums or doesn't. The behavior between versions is nuts.
% arm-oe-linux-gnueabi-gcc --version
arm-oe-linux-gnueabi-gcc (GCC) 8.2.0
So I need this fix when building for my embedded platform using a compiler from the Yocto SDK. Thanks for applying.
My up-to-date host compiler has no complaints regarding enums :)
But with gcc-9.1 I get a few of these now:
../git/gisi/modem.c: In function ‘modem_subs_update’:../git/gisi/modem.c:383:3: error: converting a packed ‘struct sockaddr_pn’ pointer (alignment 1) to a ‘const struct sockaddr’ pointer (alignment 2) may result in an unaligned pointer value [-Werror=address-of-packed-member]
383 | sizeof(commgr));
| ^~~~~~
In file included from ../git/gisi/message.h:32,
from ../git/gisi/modem.c:36:
../git/gisi/phonet.h:49:8: note: defined here
49 | struct sockaddr_pn {
| ^~~~~~~~~~~It's not a problem though, since I don't enable gisi in my build - now you know :)
// Martin
Hi Martin,
Quoted 17 lines · Martin Hundebøll
Hi Denis,
Quoted 3 lines · Denis Kenzior
What compiler are you using? gcc really needs to make up its mind whether it warns about enums or doesn't. The behavior between versions is nuts.
% arm-oe-linux-gnueabi-gcc --version
arm-oe-linux-gnueabi-gcc (GCC) 8.2.0So I need this fix when building for my embedded platform using a compiler from the Yocto SDK. Thanks for applying.
My up-to-date host compiler has no complaints regarding enums :)
But with gcc-9.1 I get a few of these now:
Quoted 13 lines
../git/gisi/modem.c: In function ‘modem_subs_update’:../git/gisi/modem.c:383:3: error: converting a packed ‘struct sockaddr_pn’ pointer (alignment 1) to a ‘const struct sockaddr’ pointer (alignment 2) may result in an unaligned pointer value [-Werror=address-of-packed-member]
383 | sizeof(commgr));
| ^~~~~~
In file included from../git/gisi/message.h:32,
from../git/gisi/modem.c:36:../git/gisi/phonet.h:49:8: note: defined here
49 | structsockaddr_pn{
| ^~~~~~~~~~~
Yeah we've seen this one as well. The problem is that there's not a whole lot we can do but #pragma this out as it is a structure that is part of the uapi.
Quoted 3 lines
It's not a problem though, since I don't enable gisi in my build - now you know :)
As do I honestly. That driver has not been maintained in some time. I'm considering removing it from the tree entirely.
Regards,
-Denis