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: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 6F4141F852 for ; Thu, 22 Dec 2022 22:01:26 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pvWipQDj"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbiLVWBL (ORCPT ); Thu, 22 Dec 2022 17:01:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiLVWBJ (ORCPT ); Thu, 22 Dec 2022 17:01:09 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 339C4DEBD for ; Thu, 22 Dec 2022 14:01:07 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id y16so2984666wrm.2 for ; Thu, 22 Dec 2022 14:01:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :message-id:from:to:cc:subject:date:message-id:reply-to; bh=W21fIF9hEVBSUj6ZpMoAYYrlg9Rl00aLRwXMNsZm/J8=; b=pvWipQDjMsBrbofySMioNFzPTKTXO8ir10G95Gl6LRycn42rKqlF30SAqpL6rappxS BL9qhXnW6X2Z1woJgQB3F6xcr0jyoZjajES1e8zXx8eAmdIrTvxzXiCzX2AtsB1VmUgz bPaZ3/XcRc5x76BPRYcTmqCEfxAV2dyXxq1OBE3+2SKMwFgzVVuCkm6wG35SGxGwcP6d gq0XMx5mdrtffL5RZgfoTPU9BEnvk4rg47qqAkcDsG4PleSd8GC7Vt/IaOWtPU6T8Ml8 d+eM/G7hpmKEKmpJSQ0cJFOFspKo7OPvKQUCethzIjnylgA9rcuZ0R/S6Nh0GEhyGvjb cq3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W21fIF9hEVBSUj6ZpMoAYYrlg9Rl00aLRwXMNsZm/J8=; b=GSKq+1uQSThG7g71TjPC+lU8xVsAgMvKIQYfk8o8yACZ2pLuGmYd/CY6P2hUxIpvBn rXSMcfjCgjedql3QRE0gjnM0ijYLjf6ou4FTtXxzESmFTeFtniqhFXodVL0+2BuE1/rY LokqJzgTxUVzhHy/1Vm9fgKCPjw/nYMAzPUkEgUzBM9A7wm9r6QPX5MTKwcB4mYFbPhZ hFILRNiuHHWp4y4j/ZGU57edwZlQh1iivyEW/g5RVx8GVJnF91cr2miJ3r4TkBLt6V3Y NhDrtRyaOvDm4Fn4IZqP5KySWR3j10H0FlC2lxb/CLDq9J0VQQC/GNXlZFTC8EtrtM98 1rdQ== X-Gm-Message-State: AFqh2koRCWlKomI+CobR7uBl4ES+362nq+fqzp9xOHuJGcJMhJ+r/6KA EFwzLZWL2jqFoo+yVPCJ+Gdw1cBSffA= X-Google-Smtp-Source: AMrXdXvDWZnxAWCMGah7cFL0SQsoAua0n+QRMBVaGLtrh9fqDM0TurUP7naWagbJ7uMYgaPQESUKuA== X-Received: by 2002:adf:fa8f:0:b0:269:13b:b6f with SMTP id h15-20020adffa8f000000b00269013b0b6fmr4855435wrr.30.1671746465506; Thu, 22 Dec 2022 14:01:05 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x15-20020a5d490f000000b00236883f2f5csm1535363wrq.94.2022.12.22.14.01.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Dec 2022 14:01:05 -0800 (PST) Message-Id: From: "Rose via GitGitGadget" Date: Thu, 22 Dec 2022 22:01:04 +0000 Subject: [PATCH] range-diff: heck for NULL over comparisons Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Rose <83477269+AtariDreams@users.noreply.github.com>, Seija Kijin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Seija Kijin Although at first it may seem easier to check for the same comparison that determined whether a_util or b_util is NULL or not, checking for null directly would make more sense for developers and static analysis tools, which false-flag this area specifically as having potential NULL pointers. Signed-off-by: Seija Kijin --- range-diff: heck for NULL over comparisons Although at first it may seem easier to check for the same comparison that determined whether a_util or b_util is NULL or not, checking for null directly would make more sense for developers and static analysis tools, which false-flag this area specifically as having potential NULL pointers. Signed-off-by: Seija Kijin doremylover123@gmail.com Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1415%2FAtariDreams%2Fmore-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1415/AtariDreams/more-v1 Pull-Request: https://github.com/git/git/pull/1415 range-diff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/range-diff.c b/range-diff.c index 8b7d81adc1b..a5f5996c0ec 100644 --- a/range-diff.c +++ b/range-diff.c @@ -506,11 +506,11 @@ static void output(struct string_list *a, struct string_list *b, b_util = j < b->nr ? b->items[j].util : NULL; /* Skip all the already-shown commits from the LHS. */ - while (i < a->nr && a_util->shown) + while (a_util && a_util->shown) a_util = ++i < a->nr ? a->items[i].util : NULL; /* Show unmatched LHS commit whose predecessors were shown. */ - if (i < a->nr && a_util->matching < 0) { + if (a_util && a_util->matching < 0) { if (!range_diff_opts->right_only) output_pair_header(&opts, patch_no_width, &buf, &dashes, a_util, NULL); @@ -519,7 +519,7 @@ static void output(struct string_list *a, struct string_list *b, } /* Show unmatched RHS commits. */ - while (j < b->nr && b_util->matching < 0) { + while (b_util && b_util->matching < 0) { if (!range_diff_opts->left_only) output_pair_header(&opts, patch_no_width, &buf, &dashes, NULL, b_util); @@ -527,7 +527,7 @@ static void output(struct string_list *a, struct string_list *b, } /* Show matching LHS/RHS pair. */ - if (j < b->nr) { + if (b_util) { a_util = a->items[b_util->matching].util; output_pair_header(&opts, patch_no_width, &buf, &dashes, a_util, b_util); base-commit: 7c2ef319c52c4997256f5807564523dfd4acdfc7 -- gitgitgadget