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

[PATCH 1/2] config: avoid yoda conditions

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 13, 2021, 06:37 UTC
Message-ID
<20210613063702.269816-2-felipe.contreras@gmail.com>
In-Reply-To
<20210613063702.269816-1-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/config.c b/config.c
index f9c400ad30..7094530b04 100644
--- a/config.c
+++ b/config.c
@@ -1232,7 +1232,7 @@ static int git_parse_maybe_bool_text(const char *value)
 int git_parse_maybe_bool(const char *value)
 {
 	int v = git_parse_maybe_bool_text(value);
-	if (0 <= v)
+	if (v >= 0)
 		return v;
 	if (git_parse_int(value, &v))
 		return !!v;
@@ -1242,7 +1242,7 @@ int git_parse_maybe_bool(const char *value)
 int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
 {
 	int v = git_parse_maybe_bool_text(value);
-	if (0 <= v) {
+	if (v >= 0) {
 		*is_bool = 1;
 		return v;
 	}
-- 
2.32.0
Previous: Felipe ContrerasNext: Felipe Contreras
Message 2 of 5 in “Trivial cleanups”
  1. 0/2 Trivial cleanupsFelipe Contreras, Jun 13, 2021
  2. 1/2 config: avoid yoda conditionsFelipe Contreras, Jun 13, 2021
  3. 2/2 add: avoid yoda conditionFelipe Contreras, Jun 13, 2021
  4. Junio C HamanoJun 15, 2021
  5. Felipe ContrerasJun 15, 2021

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.