[PATCH v2 2/3] merge-ort: add comment to avoid surprise with new sub_flag variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Elijah Newren <newren@xxxxxxxxx>

Commit 4057523a40 ("submodule merge: update conflict error message",
2022-08-04) added a sub_flag variable that is used to store a value from
enum conflict_and_info_types, but initializes it with an invalid value
of -1.  The code may never set it to a valid value, and use the invalid
one.  This can be surprising when reading over the code at first, but it
was intentional.  Add a comment making it clear that it is okay to be
using an invalid value, due to how it is used later.

Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
---
 merge-ort.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/merge-ort.c b/merge-ort.c
index 67159fc6ef9..0a935a8135f 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -1886,7 +1886,7 @@ cleanup:
 		const char *abbrev;
 
 		util = xmalloc(sizeof(*util));
-		util->flag = sub_flag;
+		util->flag = sub_flag; /* May still be -1 */
 		util->abbrev = NULL;
 		if (!sub_not_initialized) {
 			abbrev = repo_find_unique_abbrev(&subrepo, b, DEFAULT_ABBREV);
-- 
gitgitgadget




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux