From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4161 invoked by alias); 24 May 2013 00:51:45 -0000 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 Received: (qmail 4149 invoked by uid 89); 24 May 2013 00:51:45 -0000 X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,SPF_PASS autolearn=ham version=3.3.1 Received: from mail-pb0-f48.google.com (HELO mail-pb0-f48.google.com) (209.85.160.48) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 24 May 2013 00:51:44 +0000 Received: by mail-pb0-f48.google.com with SMTP id md12so3554002pbc.21 for ; Thu, 23 May 2013 17:51:42 -0700 (PDT) X-Received: by 10.68.221.201 with SMTP id qg9mr6710214pbc.87.1369356702613; Thu, 23 May 2013 17:51:42 -0700 (PDT) Received: from [192.168.0.112] ([124.160.24.211]) by mx.google.com with ESMTPSA id fm2sm14883279pab.13.2013.05.23.17.51.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 17:51:41 -0700 (PDT) Message-ID: <519EBAE8.9030909@gmail.com> Date: Fri, 24 May 2013 00:51:00 -0000 From: asmwarrior User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0a1 MIME-Version: 1.0 To: Tom Tromey CC: gdb-patches@sourceware.org Subject: Re: [PATCH 28/40] use explicit returns to avoid checker confusion References: <27ac4476e9e4f7a238ca9f86ec955ef6d2d21c02.1368124285.git.tromey@redhat.com> In-Reply-To: <27ac4476e9e4f7a238ca9f86ec955ef6d2d21c02.1368124285.git.tromey@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-05/txt/msg00896.txt.bz2 On 2013-5-10 2:52, Tom Tromey wrote: > The checker does not understand the idiom > > if (except.reason < 0) { > do_cleanups (whatever); > GDB_PY_HANDLE_EXCEPTION (except); > } > > because it doesn't realize that the nested 'if' actually has the same > condition. > > This fixes instances of this to be more explicit. > > * python/py-breakpoint.c (bppy_get_commands): Use > explicit, unconditional return. > * python/py-frame.c (frapy_read_var): Likewise. > * python/python.c (gdbpy_decode_line): Likewise. > --- > gdb/python/py-breakpoint.c | 2 +- > gdb/python/py-frame.c | 2 +- > gdb/python/python.c | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c > index d099892..fd13811 100644 > --- a/gdb/python/py-breakpoint.c > +++ b/gdb/python/py-breakpoint.c > @@ -492,7 +492,7 @@ bppy_get_commands (PyObject *self, void *closure) > if (except.reason < 0) > { > do_cleanups (chain); > - GDB_PY_HANDLE_EXCEPTION (except); > + return gdbpy_convert_exception (except); > } > > cmdstr = ui_file_xstrdup (string_file, &length); > diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c > index 33d0bd0..10a50ea 100644 > --- a/gdb/python/py-frame.c > +++ b/gdb/python/py-frame.c > @@ -472,7 +472,7 @@ frapy_read_var (PyObject *self, PyObject *args) > if (except.reason < 0) > { > do_cleanups (cleanup); > - GDB_PY_HANDLE_EXCEPTION (except); > + return gdbpy_convert_exception (except); > } > > if (!var) > diff --git a/gdb/python/python.c b/gdb/python/python.c > index 67d06e5..c4be31b 100644 > --- a/gdb/python/python.c > +++ b/gdb/python/python.c > @@ -644,7 +644,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) > { > do_cleanups (cleanups); > /* We know this will always throw. */ > - GDB_PY_HANDLE_EXCEPTION (except); > + return gdbpy_convert_exception (except); > } > > if (sals.nelts) > I see a compiler error: mingw32-gcc -O0 -g -D__USE_MINGW_ACCESS -I. -I../../archer/gdb -I../../archer/gdb/common -I../../archer/gdb/config -DLOCALEDIR="\"/mingw/share/locale\"" -DHAVE_CONFIG_H -I../../archer/gdb/../include/opcode -I../../archer/gdb/../opcodes/.. -I../../archer/gdb/../readline/.. -I../bfd -I../../archer/gdb/../bfd -I../../archer/gdb/../include -I../libdecnumber -I../../archer/gdb/../libdecnumber -I../../archer/gdb/gnulib/import -Ibuild-gnulib/import -IE:/code/python27/include -IE:/code/python27/include -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wno-format -Werror -c -o python.o -MT python.o -MMD -MP -MF .deps/python.Tpo -fno-strict-aliasing -DNDEBUG -fwrapv ../../archer/gdb/python/python.c ../../archer/gdb/python/python.c: In function 'gdbpy_decode_line': ../../archer/gdb/python/python.c:656:7: error: void value not ignored as it ought to be make[2]: *** [python.o] Error 1 make[2]: Leaving directory `/f/build_gdb/abuild/gdb' make[1]: *** [all-gdb] Error 2 make[1]: Leaving directory `/f/build_gdb/abuild' make: *** [all] Error 2 I see that: gdbpy_convert_exception (except) return a "void" type, but the function gdbpy_decode_line() need to return a "PyObject *" The macro GDB_PY_HANDLE_EXCEPTION (except) did return a NULL, see: /* Use this after a TRY_EXCEPT to throw the appropriate Python exception. */ #define GDB_PY_HANDLE_EXCEPTION(Exception) \ do { \ if (Exception.reason < 0) \ { \ gdbpy_convert_exception (Exception); \ return NULL; \ } \ } while (0) So, what about: gdbpy_convert_exception (except); return NULL; Yuanhui Zhang