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=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS 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 79B5A1F670 for ; Thu, 14 Oct 2021 17:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233169AbhJNRk0 (ORCPT ); Thu, 14 Oct 2021 13:40:26 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:51433 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbhJNRkZ (ORCPT ); Thu, 14 Oct 2021 13:40:25 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id B768015659E; Thu, 14 Oct 2021 13:38:20 -0400 (EDT) (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:content-transfer-encoding; s=sasl; bh=1HB9EJSjJtia /q62nGE813YxkHtFPOdhOlA5Yg9Ec9k=; b=EdgSopbQeXZCeaKFZNKaHV47gWXl W4TBc5K+aPDprX//sZH2FmpQviDjoxyKcZlHeARviH6qllIXBP+yotDrV0Fo1zeq J2f4ticzNpBeaSLwApiBOOult0kZMo4aXfSTgqdieykq1Rs9BZ5sPfUJfOkv2RSm NDkBP1g25GnV6p0= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id B000315659D; Thu, 14 Oct 2021 13:38:20 -0400 (EDT) (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-smtp21.pobox.com (Postfix) with ESMTPSA id 211B715659C; Thu, 14 Oct 2021 13:38:18 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Cc: git@vger.kernel.org, Elijah Newren , Martin =?utf-8?Q?=C3=85gren?= , Andrzej Hunt , Jeff King Subject: Re: [PATCH v2 5/7] ls-files: fix a trivial dir_clear() leak References: <8735p5hwg6.fsf@evledraar.gmail.com> <87lf2wh2fu.fsf@evledraar.gmail.com> Date: Thu, 14 Oct 2021 10:38:16 -0700 In-Reply-To: <87lf2wh2fu.fsf@evledraar.gmail.com> (=?utf-8?B?IsOGdmFyIEFy?= =?utf-8?B?bmZqw7Zyw7A=?= Bjarmason"'s message of "Thu, 14 Oct 2021 02:15:32 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 X-Pobox-Relay-ID: 8475AB16-2D15-11EC-87B0-98D80D944F46-77302942!pb-smtp21.pobox.com Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason writes: > On Wed, Oct 13 2021, Junio C Hamano wrote: > >> =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason writes: >> >>> - if (ps_matched) { >>> - int bad; >>> - bad =3D report_path_error(ps_matched, &pathspec); >>> - if (bad) >>> - fprintf(stderr, "Did you forget to 'git add'?= \n"); >>> - >>> - return bad ? 1 : 0; >>> + if (ps_matched && report_path_error(ps_matched, &pathspec)) { >>> + fprintf(stderr, "Did you forget to 'git add'?\n"); >>> + ret =3D 1; >>> } ... > I mean that we generally don't write code like: > > if (x) { > if (y) { > fprintf(...); > ret =3D 1; > } > } > > And instead write: > > if (x && y) { > fprintf(...); > ret =3D 1; > } > > So aside from the specific change here I thought your objection would > also apply to e.g. removing braces from a standalone "if" as it's > reduced to a one statement body, which we we generally do. Yes, but in a "plug-leak-only" fix, I would have expected if (ps_matched) { int bad; bad =3D report_path_error(ps_matched, &pathspec); if (bad) fprintf(stderr, "Did you forget to 'git add'?\n"); - return bad ? 1 : 0; + ret =3D bad ? 1 : 0; } Doing anything more than that is "while at it clean-up".