From f89b38947a4f8e76a38662f0ea04e3ceffbc5e72 Mon Sep 17 00:00:00 2001 From: thorkill Date: Mon, 29 Jun 2015 11:56:27 +0200 Subject: [PATCH] initialize variables used in conditional jumps Errors detected by clang -Wconditional-uninitialized. --- src/info.c | 6 +++--- src/invitation.c | 10 +++++----- src/net_packet.c | 4 ++-- src/subnet_parse.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/info.c b/src/info.c index b9a6fcf9..9b84cec0 100644 --- a/src/info.c +++ b/src/info.c @@ -59,14 +59,14 @@ static int info_node(int fd, const char *item) { char via[4096]; char nexthop[4096]; int code, req, cipher, digest, maclength, compression, distance; - short int pmtu, minmtu, maxmtu; - unsigned int options; + short int pmtu = -1, minmtu = 0, maxmtu = 0; + unsigned int options = -1; union { node_status_t bits; uint32_t raw; } status_union; node_status_t status; - long int last_state_change; + long int last_state_change = -1; while(recvline(fd, line, sizeof line)) { int n = sscanf(line, "%d %d %s %s %s port %s %d %d %d %d %x %"PRIx32" %s %s %d %hd %hd %hd %ld", &code, &req, node, id, host, port, &cipher, &digest, &maclength, &compression, &options, &status_union.raw, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change); diff --git a/src/invitation.c b/src/invitation.c index 3102e416..ebed38dd 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -310,7 +310,7 @@ int cmd_invite(int argc, char *argv[]) { fprintf(stderr, "Error while reading directory %s: %s\n", filename, strerror(errno)); return 1; } - + ecdsa_t *key; snprintf(filename, sizeof filename, "%s" SLASH "invitations" SLASH "ed25519_key.priv", confbase); @@ -573,7 +573,7 @@ make_names: snprintf(temp_netname, sizeof temp_netname, "join_%x", rand()); netname = temp_netname; goto make_names; - } + } if(mkdir(confbase, 0777) && errno != EEXIST) { fprintf(stderr, "Could not create directory %s: %s\n", confbase, strerror(errno)); @@ -605,7 +605,7 @@ make_names: // Filter first chunk on approved keywords, split between tinc.conf and hosts/Name // Other chunks go unfiltered to their respective host config files const char *p = data; - char *l, *value; + char *l = NULL, *value = NULL; while((l = get_line(&p))) { // Ignore comments @@ -971,7 +971,7 @@ next: return 1; } - + ecdsa_t *hiskey = ecdsa_set_base64_public_key(fingerprint); if(!hiskey) return 1; @@ -1001,7 +1001,7 @@ next: p += done; } } - + sptps_stop(&sptps); ecdsa_free(hiskey); ecdsa_free(key); diff --git a/src/net_packet.c b/src/net_packet.c index 91a642ca..3b157689 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -713,7 +713,7 @@ static void send_udppacket(node_t *n, vpn_packet_t *origpkt) { /* Send the packet */ const sockaddr_t *sa = NULL; - int sock; + int sock = -1; if(n->status.send_locally) choose_local_address(n, &sa, &sock); @@ -795,7 +795,7 @@ bool send_sptps_data(node_t *to, node_t *from, int type, const void *data, size_ memcpy(buf_ptr, data, len); buf_ptr += len; const sockaddr_t *sa = NULL; - int sock; + int sock = -1; if(relay->status.send_locally) choose_local_address(relay, &sa, &sock); if(!sa) diff --git a/src/subnet_parse.c b/src/subnet_parse.c index c919b59a..7883bbf0 100644 --- a/src/subnet_parse.c +++ b/src/subnet_parse.c @@ -311,7 +311,7 @@ bool net2str(char *netstr, int len, const subnet_t *subnet) { return false; } - int result; + int result = 0; int prefixlength = -1; switch (subnet->type) { case SUBNET_MAC: