threads / patch / 34058

patchunpack-trees: improve maintainability

Subject: [PATCH] unpack-trees: improve maintainability

## tl;dr

One message between Jun 7, 2013 and Jun 7, 2013. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Felipe Contreras· Jun 7, 2013, 22:23 UTC · lore

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(-)
Show changes to unpack-trees.c +3 −2
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

← back to recent threads