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

[PATCH 1/6] diff.c: remove useless check for value != NULL

From
Christian Couder <chriscool@tuxfamily.org>
Date
Feb 16, 2008, 04:59 UTC
Message-ID
<20080216055953.d5fafe10.chriscool@tuxfamily.org>

It is not necessary to check if value != NULL before calling 'parse_lldiff_command' as there is already a check inside this function.

By the way this patch also improves the existing check inside
'parse_lldiff_command' by using:
	return config_error_nonbool(var);
instead of:
	return error("%s: lacks value", var);
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 diff.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
	This patch series can be applied on "master"
	on top of my "diff.c: strdup -> xstrdup" patch. 
	The first 3 patches apply cleanly on "next" though.
diff --git a/diff.c b/diff.c
index e5db293..5640cbf 100644
--- a/diff.c
+++ b/diff.c
@@ -87,7 +87,7 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val
 	}
 
 	if (!value)
-		return error("%s: lacks value", var);
+		return config_error_nonbool(var);
 	drv->cmd = xstrdup(value);
 	return 0;
 }
@@ -166,13 +166,8 @@ int git_diff_ui_config(const char *var, const char *value)
 	if (!prefixcmp(var, "diff.")) {
 		const char *ep = strrchr(var, '.');
 
-		if (ep != var + 4) {
-			if (!strcmp(ep, ".command")) {
-				if (!value)
-					return config_error_nonbool(var);
-				return parse_lldiff_command(var, ep, value);
-			}
-		}
+		if (ep != var + 4 && !strcmp(ep, ".command"))
+			return parse_lldiff_command(var, ep, value);
 	}
 
 	return git_diff_basic_config(var, value);
-- 
1.5.4.1.129.gf12af-dirty
Next: Junio C Hamano
Message 1 of 2 in “diff.c: remove useless check for value != NULL”
  1. 1/6 diff.c: remove useless check for value != NULLChristian Couder, Feb 16, 2008
  2. Junio C HamanoFeb 16, 2008

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.