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

Re: [PATCH 1/5] notes-utils: handle boolean notes.rewritemode correctly

From
David Kastrup <dak@gnu.org>
Date
Feb 16, 2014, 16:22 UTC
Message-ID
<87txbzvxgq.fsf@fencepost.gnu.org>
In-Reply-To
<be9b384ec77fc39b939b8c5505862a6e1c641faa.1392565571.git.john@keeping.me.uk>
John Keeping <john@keeping.me.uk> writes:
> If we carry on after outputting config_error_nonbool then we're
> guaranteed to dereference a null pointer.
Not really relevant to this patch, but looking at the output of
git grep config_error_nonbool

seems like a serious amount of ridiculousness going on. The header shows

cache.h:extern int config_error_nonbool(const char *); cache.h:#define config_error_nonbool(s) (config_error_nonbool(s), -1)

and the implementation

config.c:#undef config_error_nonbool config.c:int config_error_nonbool(const char *var)

Presumably this was done so that the uses of config_error_nonbool can be recognized as returning -1 unconditionally.

But is that worth the obfuscation? Why not let config_error_nonbool return -1 in the first place? It does not appear like any caller would call the function rather than the macro, so why declare the function as returning an int at all? And why give it the same name as the macro (risking human/computer confusion and requiring an explicit #undef for the definition or was that declaration?) instead of config_error_nonbool_internal or whatever else?

-- 
David Kastrup
Previous: John KeepingNext: Jeff King
Message 3 of 13 in “Miscellaneous fixes from static analysis”
  1. 0/5 Miscellaneous fixes from static analysisJohn Keeping, Feb 16, 2014
  2. 1/5 notes-utils: handle boolean notes.rewritemode correctlyJohn Keeping, Feb 16, 2014
  3. David KastrupFeb 16, 2014
  4. Jeff KingFeb 18, 2014
  5. David KastrupFeb 18, 2014
  6. Jeff KingFeb 18, 2014
  7. David KastrupFeb 18, 2014
  8. 2/5 utf8: fix iconv error detectionJohn Keeping, Feb 16, 2014
  9. 3/5 utf8: use correct type for values in interval tableJohn Keeping, Feb 16, 2014
  10. 4/5 builtin/mv: don't use memory after freeJohn Keeping, Feb 16, 2014
  11. 5/5 streaming: simplify attaching a filterJohn Keeping, Feb 16, 2014
  12. Junio C HamanoFeb 18, 2014
  13. Junio C HamanoFeb 19, 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.