[obv] Fix unused-but-set-variable error [Re: [OB] Fix linux-low.c build error]

Jan Kratochvil jan.kratochvil@redhat.com
Sun Dec 18 22:55:00 GMT 2011


On Sun, 18 Dec 2011 20:22:39 +0100, Jan Kratochvil wrote:
> (c) With these GCCs
> 	FSF: gcc (GCC) 4.6.3 20111218 (prerelease)
> 	FSF: gcc (GCC) 4.7.0 20111218 (experimental)
[...]
> 	linux-low.c: In function ‘linux_create_inferior’:
> 	linux-low.c:577:8: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]

Checked in this alternative fix to not break the next nightly builds.

I believe it now should pass also on Ubuntu, tested it with artificial
warn_unused_result attribute for `write'.


Regards,
Jan


http://sourceware.org/ml/gdb-cvs/2011-12/msg00185.html

--- src/gdb/gdbserver/ChangeLog	2011/12/18 15:49:04	1.529
+++ src/gdb/gdbserver/ChangeLog	2011/12/18 20:55:08	1.530
@@ -1,3 +1,11 @@
+2011-12-18  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* linux-low.c (linux_create_inferior): Put empty if clause for write.
+
+	Revert:
+	2011-12-18  Hui Zhu  <teawater@gmail.com>
+	* linux-low.c (linux_create_inferior): Save return value to ret.
+
 2011-12-18  Hui Zhu  <teawater@gmail.com>
 
 	* linux-low.c (linux_create_inferior): Save return value to ret.
--- src/gdb/gdbserver/linux-low.c	2011/12/18 15:49:04	1.186
+++ src/gdb/gdbserver/linux-low.c	2011/12/18 20:55:08	1.187
@@ -574,12 +574,12 @@
 	 Also, redirect stdin to /dev/null.  */
       if (remote_connection_is_stdio ())
 	{
-	  int ret;
 	  close (0);
 	  open ("/dev/null", O_RDONLY);
 	  dup2 (2, 1);
-	  ret = write (2, "stdin/stdout redirected\n",
-		       sizeof ("stdin/stdout redirected\n") - 1);
+	  if (write (2, "stdin/stdout redirected\n",
+		     sizeof ("stdin/stdout redirected\n") - 1) < 0)
+	    /* Errors ignored.  */;
 	}
 
       execv (program, allargs);



More information about the Gdb-patches mailing list