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

[PATCH 2/3] Revert "silence some -Wuninitialized false positives"

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 4, 2014, 06:12 UTC
Message-ID
<1399183975-2346-3-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1399183975-2346-1-git-send-email-felipe.contreras@gmail.com>
In recent versions of gcc (4.9.0), we get a few of these:
  notes.c: In function ‘notes_display_config’:
  notes.c:970:28: warning: right-hand operand of comma expression has no effect [-Wunused-value]
      config_error_nonbool(k);
                            ^
Previous commit explains the reason.
This reverts commit a469a1019352b8efc4bd7003b0bd59eb60fc428c.
Conflicts:
	cache.h
	parse-options.h
---
 cache.h         |  3 ---
 config.c        |  1 -
 parse-options.c | 18 +++++++++---------
 parse-options.h |  4 ----
 4 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/cache.h b/cache.h
index 107ac61..fae077a 100644
--- a/cache.h
+++ b/cache.h
@@ -1271,9 +1271,6 @@ extern int check_repository_format_version(const char *var, const char *value, v
 extern int git_env_bool(const char *, int);
 extern int git_config_system(void);
 extern int config_error_nonbool(const char *);
-#if defined(__GNUC__) && ! defined(__clang__)
-#define config_error_nonbool(s) (config_error_nonbool(s), -1)
-#endif
 extern const char *get_log_output_encoding(void);
 extern const char *get_commit_output_encoding(void);
 
diff --git a/config.c b/config.c
index a30cb5c..0083674 100644
--- a/config.c
+++ b/config.c
@@ -1870,7 +1870,6 @@ int git_config_rename_section(const char *old_name, const char *new_name)
  * Call this to report error for your variable that should not
  * get a boolean value (i.e. "[my] var" means "true").
  */
-#undef config_error_nonbool
 int config_error_nonbool(const char *var)
 {
 	return error("Missing value for '%s'", var);
diff --git a/parse-options.c b/parse-options.c
index b536896..2b4b8e5 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -19,6 +19,15 @@ int optbug(const struct option *opt, const char *reason)
 	return error("BUG: switch '%c' %s", opt->short_name, reason);
 }
 
+int opterror(const struct option *opt, const char *reason, int flags)
+{
+	if (flags & OPT_SHORT)
+		return error("switch `%c' %s", opt->short_name, reason);
+	if (flags & OPT_UNSET)
+		return error("option `no-%s' %s", opt->long_name, reason);
+	return error("option `%s' %s", opt->long_name, reason);
+}
+
 static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt,
 		   int flags, const char **arg)
 {
@@ -632,12 +641,3 @@ static int parse_options_usage(struct parse_opt_ctx_t *ctx,
 	return usage_with_options_internal(ctx, usagestr, opts, 0, err);
 }
 
-#undef opterror
-int opterror(const struct option *opt, const char *reason, int flags)
-{
-	if (flags & OPT_SHORT)
-		return error("switch `%c' %s", opt->short_name, reason);
-	if (flags & OPT_UNSET)
-		return error("option `no-%s' %s", opt->long_name, reason);
-	return error("option `%s' %s", opt->long_name, reason);
-}
diff --git a/parse-options.h b/parse-options.h
index 3189676..3b140d0 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -176,10 +176,6 @@ extern NORETURN void usage_msg_opt(const char *msg,
 
 extern int optbug(const struct option *opt, const char *reason);
 extern int opterror(const struct option *opt, const char *reason, int flags);
-#if defined(__GNUC__) && ! defined(__clang__)
-#define opterror(o,r,f) (opterror((o),(r),(f)), -1)
-#endif
-
 /*----- incremental advanced APIs -----*/
 
 enum {
-- 
1.9.2+fc1.20.g204a630
Previous: Jeff KingNext: Felipe Contreras
Message 19 of 26 in “Fix a ton of compiler warnings”
  1. 0/3 Fix a ton of compiler warningsFelipe Contreras, May 4, 2014
  2. 1/3 Revert "make error()'s constant return value more visible"Felipe Contreras, May 4, 2014
  3. Jeff KingMay 5, 2014
  4. Felipe ContrerasMay 5, 2014
  5. Jeff KingMay 5, 2014
  6. Felipe ContrerasMay 5, 2014
  7. Jeff KingMay 5, 2014
  8. Felipe ContrerasMay 5, 2014
  9. Jeff KingMay 5, 2014
  10. 1/2 inline constant return from error() functionJeff King, May 6, 2014
  11. Junio C HamanoMay 6, 2014
  12. Jeff KingMay 7, 2014
  13. Junio C HamanoMay 11, 2014
  14. Jeff KingMay 12, 2014
  15. Felipe ContrerasMay 11, 2014
  16. Jonathan NiederMay 12, 2014
  17. Jeff KingMay 12, 2014
  18. 2/2 let clang use the constant-return error() macroJeff King, May 6, 2014
  19. 2/3 Revert "silence some -Wuninitialized false positives"Felipe Contreras, May 4, 2014
  20. 3/3 Silence a bunch of format-zero-length warningsFelipe Contreras, May 4, 2014
  21. brian m. carlsonMay 4, 2014
  22. Felipe ContrerasMay 4, 2014
  23. Jeff KingMay 5, 2014
  24. Junio C HamanoMay 7, 2014
  25. Heiko VoigtMay 7, 2014
  26. Junio C HamanoMay 7, 2014

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.