public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Fix compiler warning in linux-namespaces.c
@ 2019-08-27 18:53 Christian Biesinger
  0 siblings, 0 replies; only message in thread
From: Christian Biesinger @ 2019-08-27 18:53 UTC (permalink / raw)
  To: gdb-cvs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 1796 bytes --]

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=550105b77914a8b06498318775b28e85c610b9a3

commit 550105b77914a8b06498318775b28e85c610b9a3
Author: Christian Biesinger <cbiesinger@google.com>
Date:   Tue Aug 27 13:22:38 2019 -0500

    Fix compiler warning in linux-namespaces.c
    
    ../../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).

Diff:
---
 gdb/ChangeLog              | 4 ++++
 gdb/nat/linux-namespaces.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c7d2dae..0028253 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c
index 503f755..e49bc1a 100644
--- a/gdb/nat/linux-namespaces.c
+++ b/gdb/nat/linux-namespaces.c
@@ -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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-27 18:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 18:53 [binutils-gdb] Fix compiler warning in linux-namespaces.c Christian Biesinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).