Fix compiler warning in linux-namespaces.c
authorChristian Biesinger <cbiesinger@google.com>
Tue, 27 Aug 2019 18:22:38 +0000 (13:22 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Tue, 27 Aug 2019 18:53:05 +0000 (13:53 -0500)
../../gdb/nat/linux-namespaces.c: In function ‘void mnsh_main(int)’:
../../gdb/nat/linux-namespaces.c:604:8: warning: ‘fd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  close (fd);
  ~~~~~~^~~~

And the warning is correct -- mnsh_recv_message can return -1 and leave fd
uninitialized, and mnsh_main will still call close (fd) if that happens.

Initialize fd to -1 to avoid that.

gdb/ChangeLog:

2019-08-27  Christian Biesinger  <cbiesinger@google.com>

* nat/linux-namespaces.c (mnsh_main): Initialize fd (to -1).

gdb/ChangeLog
gdb/nat/linux-namespaces.c

index c7d2dae4ffa6fc5a4db0ed2d237885d476c22fab..002825312c3f1e93f8bf2572b81beaf830d4c779 100644 (file)
@@ -1,3 +1,7 @@
+2019-08-27  Christian Biesinger  <cbiesinger@google.com>
+
+       * nat/linux-namespaces.c (mnsh_main): Initialize fd (to -1).
+
 2019-08-27  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * cli/cli-utils.c (info_print_options_defs): Delete.
index 503f755903c4dbacac6316a853f7a753577afe95..e49bc1ade36f73710cbe21911449b5710e762fc2 100644 (file)
@@ -562,7 +562,7 @@ mnsh_main (int sock)
   while (1)
     {
       enum mnsh_msg_type type;
-      int fd, int1, int2;
+      int fd = -1, int1, int2;
       char buf[PATH_MAX];
       ssize_t size, response = -1;
 
This page took 0.030274 seconds and 4 git commands to generate.