aboutsummaryrefslogtreecommitdiffstats
path: root/src/socket.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-07-15 13:08:08 +0200
committerlaforge <laforge@osmocom.org>2021-07-16 16:01:30 +0000
commit6fe865daae9dd1823eb98c819d4f99b4f0d5ac23 (patch)
tree2ba31c7054b9e30ac1ee2a398e3e7d17aaa20e4f /src/socket.c
parent8a482fd0a85cba32e8cfb484e3a3f4cbaf4eb894 (diff)
Make gcc 11.1.0 false positivies happy
After my system's gcc was upgraded, I get false positivies in a couple places. Let's initialize those to make gcc happy. """ /git/libosmocore/src/socket.c: In function ‘osmo_sock_init’: /git/libosmocore/src/socket.c:958:25: error: ‘sfd’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 958 | close(sfd); | ^~~~~~~~~~ /git/libosmocore/src/gsm/gsm48.c: In function ‘osmo_mobile_identity_decode’: /git/libosmocore/src/gsm/gsm48.c:690:20: error: ‘str_size’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 690 | if (rc < 1 || rc >= str_size) { | ~~~~~~~^~~~~~~~~~~~~~~~~ /git/libosmocore/src/gsm/gsm48.c:679:22: error: ‘str’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 679 | rc = osmo_bcd2str(str, str_size, mi_data, 1, 1 + nibbles_len, allow_hex); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """ Change-Id: I8aacfbc21e23f63a65e8baee3fd536a1fe1bdd8a
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/socket.c b/src/socket.c
index 34972b88..19d48e4f 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -894,7 +894,9 @@ int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto,
const char *host, uint16_t port, unsigned int flags)
{
struct addrinfo *result, *rp;
- int sfd, rc, on = 1;
+ int sfd = -1; /* initialize to avoid uninitialized false warnings on some gcc versions (11.1.0) */
+ int on = 1;
+ int rc;
if ((flags & (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) ==
(OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) {