From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,URIBL_CSS,URIBL_CSS_A shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 643551F953 for ; Thu, 6 Jan 2022 22:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244784AbiAFWOv (ORCPT ); Thu, 6 Jan 2022 17:14:51 -0500 Received: from pb-smtp2.pobox.com ([64.147.108.71]:60410 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244435AbiAFWOu (ORCPT ); Thu, 6 Jan 2022 17:14:50 -0500 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 9CFC41076ED; Thu, 6 Jan 2022 17:14:49 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=OIGt0SDMjV1PR4l+p0F9/j6VJ4NR3aU5ioo0op 9m1BU=; b=kF1oG+lOAhepFIGd7pvnyBn30LrhgxGWub6Sd73I14dFYZ3Q14oJ0L RKWVU+60bOy/Rljp/uPn26hrI/WVRurR+wTCGnpnldrw8fqShn9oq9hb5FvuS5Pg joi3fo2YHt/9uYHpqqkz0LF7xtDmlAOrcNkbhmc1/HfDpeLz60rdU= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 9417A1076EC; Thu, 6 Jan 2022 17:14:49 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id EC74E1076EA; Thu, 6 Jan 2022 17:14:48 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: Taylor Blau Cc: git@vger.kernel.org, l.s.r@web.de Subject: Re: [PATCH 2/2] grep: use grep_and_expr() in compile_pattern_and() References: <71bd2d1bcc6486f2e21c649708d3f4fa67dc162c.1641498525.git.me@ttaylorr.com> Date: Thu, 06 Jan 2022 14:14:47 -0800 In-Reply-To: <71bd2d1bcc6486f2e21c649708d3f4fa67dc162c.1641498525.git.me@ttaylorr.com> (Taylor Blau's message of "Thu, 6 Jan 2022 14:50:15 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 1010F274-6F3E-11EC-B952-CB998F0A682E-77302942!pb-smtp2.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Taylor Blau writes: > In a similar spirit as a previous commit, use the new `grep_and_expr()` > to construct the AND node in `compile_pattern_and()`. > > Unlike the aforementioned previous commit, this is not about code > duplication, since this is the only spot in grep.c where an AND node is > constructed. Rather, this is about visual consistency with the other > `compile_pattern_xyz()` functions. > > Signed-off-by: Taylor Blau > --- > grep.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/grep.c b/grep.c > index d772fe6cc5..ab4fdacaed 100644 > --- a/grep.c > +++ b/grep.c > @@ -619,6 +619,11 @@ static struct grep_expr *grep_or_expr(struct grep_expr *left, struct grep_expr * > return grep_binexp(GREP_NODE_OR, left, right); > } > > +static struct grep_expr *grep_and_expr(struct grep_expr *left, struct grep_expr *right) > +{ > + return grep_binexp(GREP_NODE_AND, left, right); > +} > + > static struct grep_expr *compile_pattern_or(struct grep_pat **); > static struct grep_expr *compile_pattern_atom(struct grep_pat **list) > { > @@ -687,11 +692,7 @@ static struct grep_expr *compile_pattern_and(struct grep_pat **list) > y = compile_pattern_and(list); > if (!y) > die("--and not followed by pattern expression"); > - CALLOC_ARRAY(z, 1); > - z->node = GREP_NODE_AND; > - z->u.binary.left = x; > - z->u.binary.right = y; > - return z; > + return grep_and_expr(x, y); You'd need to remove 'z' from the function to avoid getting yelled at by your compiler for unused variable.