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

[PATCH] remove tests of always-false condition

From
Jim Meyering <jim@meyering.net>
Date
May 26, 2011, 13:58 UTC
Message-ID
<87zkm95zt3.fsf@rho.meyering.net>
* fsck.c (fsck_error_function): Don't test obj->sha1 == 0.
It can never be true, since that sha1 member is an array.
* transport.c (set_upstreams): Likewise for ref->new_sha1.
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
Fix some coverity-spotted nits.
Relative to "next".
 fsck.c      |    2 +-
 transport.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fsck.c b/fsck.c
index 6f266c1..60bd4bb 100644
--- a/fsck.c
+++ b/fsck.c
@@ -349,7 +349,7 @@ int fsck_error_function(struct object *obj, int type, const char *fmt, ...)
 	va_list ap;
 	struct strbuf sb = STRBUF_INIT;

-	strbuf_addf(&sb, "object %s:", obj->sha1?sha1_to_hex(obj->sha1):"(null)");
+	strbuf_addf(&sb, "object %s:", sha1_to_hex(obj->sha1));

 	va_start(ap, fmt);
 	strbuf_vaddf(&sb, fmt, ap);
diff --git a/transport.c b/transport.c
index 1a3998e..c9c8056 100644
--- a/transport.c
+++ b/transport.c
@@ -156,7 +156,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
 			continue;
 		if (!ref->peer_ref)
 			continue;
-		if (!ref->new_sha1 || is_null_sha1(ref->new_sha1))
+		if (is_null_sha1(ref->new_sha1))
 			continue;

 		/* Follow symbolic refs (mainly for HEAD). */
--
1.7.5.2.660.g9f46c
Next: Junio C Hamano
Message 1 of 2 in “remove tests of always-false condition”
  1. remove tests of always-false conditionJim Meyering, May 26, 2011
  2. Junio C HamanoMay 26, 2011

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.