From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22450 invoked by alias); 19 Dec 2011 06:50:28 -0000 Received: (qmail 22437 invoked by uid 22791); 19 Dec 2011 06:50:26 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,TW_CP X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Dec 2011 06:50:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id ACC802BB029; Mon, 19 Dec 2011 01:50:12 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yEK6-vaZcS3R; Mon, 19 Dec 2011 01:50:12 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id C3D732BB02E; Mon, 19 Dec 2011 01:50:10 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id BB674145615; Sun, 18 Dec 2011 22:50:02 -0800 (PST) Date: Mon, 19 Dec 2011 06:53:00 -0000 From: Joel Brobecker To: Yao Qi Cc: Jan Kratochvil , Hui Zhu , gdb-patches ml Subject: Re: [obv] Fix unused-but-set-variable error [Re: [OB] Fix linux-low.c build error] Message-ID: <20111219065002.GQ21915@adacore.com> References: <20111218192239.GA25401@host2.jankratochvil.net> <20111218205826.GA15385@host2.jankratochvil.net> <4EEED8FB.4040103@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4EEED8FB.4040103@codesourcery.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-12/txt/msg00623.txt.bz2 > This reminds me that I committed a similar patch some days ago. Here is a > patch to revert. > > -- > Yao (??????) > > * tracepoint.c (gdb_ust_thread): Put an empty if clause for write. > > Revert: > 2011-12-14 Yao Qi > * tracepoint.c (gdb_ust_thread): Don't ignore return value > of write. Thanks! This begs the question, though: Why is it OK to ignore the error? I am looking at the code and, not knowing much about tracepoints, I don't understand well the prupose of gdb_ust_thread (hint: No function description). As far as I can tell, the write is simply writing the byte that was read from the connection back to it. What will happen if we fail to write, and should the user be warned, for instance? IIRC, in the previous case, we were simply writing to stderr, I think, and there wasn't much else we could do if that failed... > Index: gdb/gdbserver/tracepoint.c > =================================================================== > RCS file: /cvs/src/src/gdb/gdbserver/tracepoint.c,v > retrieving revision 1.38 > diff -u -r1.38 tracepoint.c > --- gdb/gdbserver/tracepoint.c 15 Dec 2011 12:40:03 -0000 1.38 > +++ gdb/gdbserver/tracepoint.c 19 Dec 2011 06:17:49 -0000 > @@ -8122,8 +8122,8 @@ > strcpy (cmd_buf, ""); > } > > - /* Fix compiler's warning: ignoring return value of 'write'. */ > - ret = write (fd, buf, 1); > + if (write (fd, buf, 1) < 0) > + /* Errors ignored. */; > close (fd); > } > } -- Joel