From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id DF2B1396981E for ; Fri, 25 Jun 2021 21:09:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DF2B1396981E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x42c.google.com with SMTP id i94so12045010wri.4 for ; Fri, 25 Jun 2021 14:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=KVP8mepREr9w5/vN/8yTr6EbLWn5z3Ii+ILkh3J4WwE=; b=G5q269J55XgKcw7ikRLRWLbrDYGl40qmzkD7JR0kI6qmBfk2u/jVYuJqfuuZB0FdQJ X3h/DTEyMewC/jbGoQVbWOcxXp4Hmr39QYxaiz5nZ6wrssqKqKz2Fp7niOcDBKbHxVeh kWaGOZFv1HPVDGyexuhK0TDB/VS0EpAq/EfLdLXq1iQngEygXNheLn0wjWLqEWSCiKnx UllqmMiDRfjjlBUU2aRG7gAJoKUmvc3OSTy2iUz189xXoY1ES669pqAHiEQyT+0mRFv5 /Gjif0kiapdsNmCWsarBPPdo3633tOQarx8hkeni4bjn01gtsiVNZISi/OIzKDA5L1AU VXLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KVP8mepREr9w5/vN/8yTr6EbLWn5z3Ii+ILkh3J4WwE=; b=kaqZxuMA5sBtS4YHNlDlItf21887Jc9qzIfyDDYZEbP8jvxHDoiOm8Pw0RxPGrB/DE WHscywmfWe1wRB5RnDg5qqXu2oPaaMWSLS/RMIFidjGaq5QC6hGI8477oAjjBc1Y7nOH N0OslOwL7gxkYOC9D4Ju/Io1mT4Z0JTJB7OpeuM2tA8vX4yhcp9c86acSpFu9u5fYg1Q 0IsUp0NKLrQI1g+46MpO7oKfO5JSN7hXL7+5I2FUcFNjhm4+ivcq6v/0LCRJQFae6yJj U/NIqDRZNTwDQnhrA5iHPrEht1xfVj8zhs0BgKSJNZnp/Me2PbAJHFhHCgEE/wgf9NmY OtsQ== X-Gm-Message-State: AOAM530dAq5z8IKCPcwOEB4s13+PuKX6EgJwgnQZNLAfyUspXeJkeiNA 92ja8ktX0zSe2o6QWBHFsianKA== X-Google-Smtp-Source: ABdhPJwAEllE5e1q2YN0Ju2c1xJ5hG+XM/y5VU4kHSWoDNpx9bTCuVZQdCNofUNSPXl6936G/GYr9w== X-Received: by 2002:a5d:474d:: with SMTP id o13mr6949707wrs.78.1624655353097; Fri, 25 Jun 2021 14:09:13 -0700 (PDT) Received: from localhost (host86-140-92-85.range86-140.btcentralplus.com. [86.140.92.85]) by smtp.gmail.com with ESMTPSA id 9sm13179538wmf.3.2021.06.25.14.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 14:09:12 -0700 (PDT) Date: Fri, 25 Jun 2021 22:09:12 +0100 From: Andrew Burgess To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/4] gdb: remove context parameter from add_setshow_enum_cmd Message-ID: <20210625210912.GU2568@embecosm.com> References: <20210625200322.3845132-1-simon.marchi@polymtl.ca> <20210625200322.3845132-4-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210625200322.3845132-4-simon.marchi@polymtl.ca> X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 22:07:13 up 9 days, 4:58, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jun 2021 21:09:15 -0000 * Simon Marchi via Gdb-patches [2021-06-25 16:03:21 -0400]: > I propose removing the context parameter from add_setshow_enum_cmd. It > was useful before add_setshow_enum_cmd returned both created commands, > as the caller couldn't easily set the context itself. But now, I think > it's fine to just let the caller do it. ChangeLog ? As non of the other add_setshow_* commands take a context, it seems reasonable to me that this should not either, hence, LGTM. Thanks, Andrew > > Change-Id: I377c4e6820ec9d5069492ed28f4cba342ce1336e > --- > gdb/cli/cli-decode.c | 7 +---- > gdb/cli/cli-style.c | 62 +++++++++++++++++++++++++++----------------- > gdb/command.h | 2 +- > 3 files changed, 40 insertions(+), 31 deletions(-) > > diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c > index f2fdeb03a285..633a3ad93095 100644 > --- a/gdb/cli/cli-decode.c > +++ b/gdb/cli/cli-decode.c > @@ -571,8 +571,7 @@ add_setshow_enum_cmd (const char *name, > cmd_const_sfunc_ftype *set_func, > show_value_ftype *show_func, > struct cmd_list_element **set_list, > - struct cmd_list_element **show_list, > - void *context) > + struct cmd_list_element **show_list) > { > set_show_commands commands > = add_setshow_cmd_full (name, theclass, var_enum, var, > @@ -580,10 +579,6 @@ add_setshow_enum_cmd (const char *name, > set_func, show_func, > set_list, show_list); > commands.set->enums = enumlist; > - > - commands.set->set_context (context); > - commands.show->set_context (context); > - > return commands; > } > > diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c > index 0b88dba56227..aca19c51b848 100644 > --- a/gdb/cli/cli-style.c > +++ b/gdb/cli/cli-style.c > @@ -230,32 +230,46 @@ cli_style_option::add_setshow_commands (enum command_class theclass, > 0, set_list); > add_show_prefix_cmd (m_name, no_class, prefix_doc, &m_show_list, > 0, show_list); > + set_show_commands commands; > + > + commands = add_setshow_enum_cmd > + ("foreground", theclass, cli_colors, > + &m_foreground, > + _("Set the foreground color for this property."), > + _("Show the foreground color for this property."), > + nullptr, > + do_set_value, > + do_show_foreground, > + &m_set_list, &m_show_list); > + commands.set->set_context (this); > + commands.show->set_context (this); > + > + commands = add_setshow_enum_cmd > + ("background", theclass, cli_colors, > + &m_background, > + _("Set the background color for this property."), > + _("Show the background color for this property."), > + nullptr, > + do_set_value, > + do_show_background, > + &m_set_list, &m_show_list); > + commands.set->set_context (this); > + commands.show->set_context (this); > > - add_setshow_enum_cmd ("foreground", theclass, cli_colors, > - &m_foreground, > - _("Set the foreground color for this property."), > - _("Show the foreground color for this property."), > - nullptr, > - do_set_value, > - do_show_foreground, > - &m_set_list, &m_show_list, (void *) this); > - add_setshow_enum_cmd ("background", theclass, cli_colors, > - &m_background, > - _("Set the background color for this property."), > - _("Show the background color for this property."), > - nullptr, > - do_set_value, > - do_show_background, > - &m_set_list, &m_show_list, (void *) this); > if (!skip_intensity) > - add_setshow_enum_cmd ("intensity", theclass, cli_intensities, > - &m_intensity, > - _("Set the display intensity for this property."), > - _("Show the display intensity for this property."), > - nullptr, > - do_set_value, > - do_show_intensity, > - &m_set_list, &m_show_list, (void *) this); > + { > + commands = add_setshow_enum_cmd > + ("intensity", theclass, cli_intensities, > + &m_intensity, > + _("Set the display intensity for this property."), > + _("Show the display intensity for this property."), > + nullptr, > + do_set_value, > + do_show_intensity, > + &m_set_list, &m_show_list); > + commands.set->set_context (this); > + commands.show->set_context (this); > + } > } > > static cmd_list_element *style_set_list; > diff --git a/gdb/command.h b/gdb/command.h > index 9413a50c2971..711cbdcf43e1 100644 > --- a/gdb/command.h > +++ b/gdb/command.h > @@ -403,7 +403,7 @@ extern set_show_commands add_setshow_enum_cmd > const char **var, const char *set_doc, const char *show_doc, > const char *help_doc, cmd_const_sfunc_ftype *set_func, > show_value_ftype *show_func, cmd_list_element **set_list, > - cmd_list_element **show_list, void *context = nullptr); > + cmd_list_element **show_list); > > extern set_show_commands add_setshow_auto_boolean_cmd > (const char *name, command_class theclass, auto_boolean *var, > -- > 2.32.0 >