From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21663 invoked by alias); 6 Mar 2011 18:48:22 -0000 Received: (qmail 21655 invoked by uid 22791); 6 Mar 2011 18:48:22 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 06 Mar 2011 18:48:12 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p26ImA39027604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 6 Mar 2011 13:48:10 -0500 Received: from host1.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p26Im8DS012706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 6 Mar 2011 13:48:10 -0500 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p26Im8ZN023065; Sun, 6 Mar 2011 19:48:08 +0100 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p26Im7WG023055; Sun, 6 Mar 2011 19:48:07 +0100 Date: Sun, 06 Mar 2011 19:00:00 -0000 From: Jan Kratochvil To: Michael Snyder Cc: "gdb-patches@sourceware.org" , Mark Kettenis Subject: Re: [RFA] i386-tdep.c, check target_read_memory for error. Message-ID: <20110306184807.GA22789@host1.jankratochvil.net> References: <4D715BB0.8030506@vmware.com> <20110306141515.GA1895@host1.jankratochvil.net> <4D73D59A.2040908@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D73D59A.2040908@vmware.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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-03/txt/msg00404.txt.bz2 On Sun, 06 Mar 2011 19:42:34 +0100, Michael Snyder wrote: > Jan Kratochvil wrote: > >On Fri, 04 Mar 2011 22:37:52 +0100, Michael Snyder wrote: > >>Call error if target_read_memory fails. > >[...] > >>- target_read_memory (pc, &op, 1); > >>+ if (target_read_memory (pc, &op, 1)) > >>+ error (_("Couldn't read memory at pc (%s)"), + paddress > >>(gdbarch, pc)); > > > >There is the function `read_memory' for such purpose. > > I don't understand the objection. target_read_memory may fail and > return an error code. Coverity reports that the return value is checked > in 78 out of 97 calling instances. So what's wrong with checking it now? I was suggesting that instead of the code if (target_read_memory (pc, &op, 1)) error (_("Couldn't read memory at pc (%s)"), paddress (gdbarch, pc)); One can write a shorter code with the same effect: read_memory (pc, &op, 1); I did not do a real patch review and I also did not write any notice about any review/approval. Mark Kettenis correctly noticed that the introduced errors (either by error or through read_memory) in some of the cases are wrong / cause regressions. Just if in some cases the error is appropriate (I do not say in which specific cases, if any) I was suggesting calling `read_memory' is more suitable than the explicit `target_read_memory'+`error' calls. Thanks, Jan