git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] range-diff: heck for NULL over comparisons
@ 2022-12-22 22:01 Rose via GitGitGadget
  2022-12-23 19:25 ` [PATCH v2] range-diff: check " Rose via GitGitGadget
  0 siblings, 1 reply; 2+ messages in thread
From: Rose via GitGitGadget @ 2022-12-22 22:01 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

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>
---
    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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH v2] range-diff: check for NULL over comparisons
  2022-12-22 22:01 [PATCH] range-diff: heck for NULL over comparisons Rose via GitGitGadget
@ 2022-12-23 19:25 ` Rose via GitGitGadget
  0 siblings, 0 replies; 2+ messages in thread
From: Rose via GitGitGadget @ 2022-12-23 19:25 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

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>
---
    range-diff: check 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-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1415/AtariDreams/more-v2
Pull-Request: https://github.com/git/git/pull/1415

Range-diff vs v1:

 1:  b0e92aaf227 ! 1:  e3d850ff3ea range-diff: heck for NULL over comparisons
     @@ Metadata
      Author: Seija Kijin <doremylover123@gmail.com>
      
       ## Commit message ##
     -    range-diff: heck for NULL over comparisons
     +    range-diff: check for NULL over comparisons
      
          Although at first it may seem easier to
          check for the same comparison that


 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-23 19:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-22 22:01 [PATCH] range-diff: heck for NULL over comparisons Rose via GitGitGadget
2022-12-23 19:25 ` [PATCH v2] range-diff: check " Rose via GitGitGadget

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).