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

[PATCH] connect: use strcmp() for string comparison

From
René Scharfe <l.s.r@web.de>
Date
Feb 21, 2015, 19:49 UTC
Message-ID
<54E8E166.7070500@web.de>

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

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 connect.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/connect.c b/connect.c
index 062e133..2a5c400 100644
--- a/connect.c
+++ b/connect.c
@@ -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;
 		}
-- 
2.3.0
Message 1 of 1 in “connect: use strcmp() for string comparison”
  1. connect: use strcmp() for string comparisonRené Scharfe, Feb 21, 2015

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.