]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
warnings: fix use of uninitialized warning
authorSami Kerola <kerolasa@iki.fi>
Mon, 22 Aug 2016 21:40:50 +0000 (22:40 +0100)
committerSami Kerola <kerolasa@iki.fi>
Wed, 24 Aug 2016 20:25:10 +0000 (21:25 +0100)
clang claims: variable 'port' is used uninitialized whenever switch default
is taken.  And that is a lie, but error() is not marked as function that
never returns, because it can also be used when printing warning.  So the
compiler is guessing wrong, but the easiest fix is to initialize the
variable rather than educate compiler.

net.c

diff --git a/net.c b/net.c
index 68ed7362d815153a94b944def5ca7231d7563305..34df68f37cfe3eb4cf724a0b629b878d2844215e 100644 (file)
--- a/net.c
+++ b/net.c
@@ -329,7 +329,7 @@ static int new_sequence(int index)
 static void net_send_tcp(int index)
 {
   int ttl, s;
-  int port;
+  int port = 0;
   int flags;
   struct sockaddr_storage local;
   struct sockaddr_storage remote;
@@ -449,7 +449,7 @@ static void net_send_sctp(int index)
 {
   int ttl, s;
   int opt = 1;
-  int port;
+  int port = 0;
   struct sockaddr_storage local;
   struct sockaddr_storage remote;
   struct sockaddr_in *local4 = (struct sockaddr_in *) &local;