git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] unpack-trees: improve maintainability

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 7, 2013, 22:23 UTC
Message-ID
<1370643787-3687-1-git-send-email-felipe.contreras@gmail.com>

Clarify that ce can be NULL by adding a check (probably more efficient also), and get rid of unnecessary indentation (since it's a single line it doesn't matter, but in the future it might).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 unpack-trees.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 57b4074..9c0100d 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -605,8 +605,9 @@ static int unpack_nondirectories(int n, unsigned long mask,
 					o);
 		for (i = 0; i < n; i++) {
 			struct cache_entry *ce = src[i + o->merge];
-			if (ce != o->df_conflict_entry)
-				free(ce);
+			if (!ce || ce == o->df_conflict_entry)
+				continue;
+			free(ce);
 		}
 		return rc;
 	}
-- 
1.8.3.698.g079b096
Message 1 of 1 in “unpack-trees: improve maintainability”
  1. unpack-trees: improve maintainabilityFelipe Contreras, Jun 7, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.