From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18293 invoked by alias); 30 Aug 2011 11:10:06 -0000 Received: (qmail 18283 invoked by uid 22791); 30 Aug 2011 11:10:04 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS 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; Tue, 30 Aug 2011 11:09:47 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7UB9jrQ014884 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Aug 2011 07:09:46 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7UB9iOr005649; Tue, 30 Aug 2011 07:09:45 -0400 From: Phil Muldoon To: matt rice Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 1/7] [python] API for macros: abort or continuing macro iterators. References: <1314198654-9008-1-git-send-email-ratmice@gmail.com> <1314198654-9008-2-git-send-email-ratmice@gmail.com> Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Tue, 30 Aug 2011 11:10:00 -0000 In-Reply-To: <1314198654-9008-2-git-send-email-ratmice@gmail.com> (matt rice's message of "Wed, 24 Aug 2011 08:10:48 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-08/txt/msg00591.txt.bz2 matt rice writes: > diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c > index d1ac7fa..e929fe0 100644 > --- a/gdb/macrocmd.c > +++ b/gdb/macrocmd.c > @@ -220,13 +220,15 @@ info_macro_command (char *name, int from_tty) > Otherwise USER_DATA is considered to be a string, printing > only macros who's NAME matches USER_DATA. Other arguments are > routed to print_macro_definition. */ > -static void > +static enum macro_walk_status > print_macro_callback (const char *name, const struct macro_definition *macro, > struct macro_source_file *source, int line, > void *user_data) > { > if (! user_data || strcmp (user_data, name) == 0) > print_macro_definition (name, macro, source, line); > + > + return macro_walk_continue; > } Is the unconditional return here due to it being part of a recursive call chain? I'm not sure what value the unconditional return of an enum constant over the previous "void" gets us? Why return anything at all? The previous version assumed the callers knew how to deal with the void return, but I am not sure what your version achieves by unconditionally returning macro_walk_continue? > /* Implementation of the "info definitions" command. */ > @@ -435,7 +437,7 @@ macro_undef_command (char *exp, int from_tty) > } > > > -static void > +static enum macro_walk_status > print_one_macro (const char *name, const struct macro_definition *macro, > struct macro_source_file *source, int line, > void *ignore) > @@ -452,6 +454,7 @@ print_one_macro (const char *name, const struct macro_definition *macro, > fprintf_filtered (gdb_stdout, ")"); > } > fprintf_filtered (gdb_stdout, " %s\n", macro->replacement); > + return macro_walk_continue; > } Same as above. If you decide to keep them please update the comment headers with a description of the return value. This function, and numerous other places too.