Skip to contentSkip to conversation

connect: use strcmp() for string comparison

PATCH New René Scharfe 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 connect: use strcmp() for string comparison

Get rid of magic string length constants and simply compare the strings using strcmp(). This makes the intent of the code a bit clearer.

---
 connect.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
connect.c +1 -2
index 062e133..2a5c400 100644
@@ -157,8 +157,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
 			server_capabilities = xstrdup(name + name_len + 1);
 		}
 
-		if (extra_have &&
-		    name_len == 5 && !memcmp(".have", name, 5)) {
+		if (extra_have && !strcmp(name, ".have")) {
 			sha1_array_append(extra_have, old_sha1);
 			continue;
 		}
Signature · 1 line
2.3.0