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

"#define precompose_argv(c,v) /* empty */" is evil

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 6, 2020, 23:47 UTC
Message-ID
<xmqqy2mribft.fsf@gitster.c.googlers.com>

I had seen an interesting compilation breakage today. A topic adds many more uses of argv-array API so I resolved semantic conflict patch until "make builtins/submodule-helper.o" passed. I failed to spot one remaining breakage until I saw

    https://travis-ci.org/github/git/git/jobs/715668996
The problematic line was
    precompose_argv(diff_args.argc, diff_args.argv);
where diff_args used to be an argv_array and is now a strvec.
Why didn't I catch this in my local test?

$ git grep -n -e precompose_argv -- \*.h compat/precompose_utf8.h:31:void precompose_argv(int argc, const char **argv); git-compat-util.h:256:#define precompose_argv(c,v)

The problematic part is this one used on all platforms other than macOS:
    /* used on Mac OS X */
    #ifdef PRECOMPOSE_UNICODE
    #include "compat/precompose_utf8.h"
    #else
    #define precompose_str(in,i_nfd2nfc)
    #define precompose_argv(c,v)
    #define probe_utf8_pathname_composition()
    #endif
I am wondering if it is a good idea to use something like
    static inline void precompose_argv(int argc, const char **argv)
    {
	; /* nothing */
    }

instead. As long as the compiler is reasonable enough, this should not result in any code change in the result, except that it would still catch wrong arguments, even if these two parameters are unused and optimized out.

Next: brian m. carlson
Message 1 of 10 in “"#define precompose_argv(c,v) /* empty */" is evil”
  1. Junio C HamanoAug 6, 2020
  2. brian m. carlsonAug 7, 2020
  3. Junio C HamanoAug 7, 2020
  4. brian m. carlsonAug 7, 2020
  5. Junio C HamanoAug 7, 2020
  6. Jeff KingAug 7, 2020
  7. Junio C HamanoAug 7, 2020
  8. Jeff KingAug 7, 2020
  9. Junio C HamanoAug 7, 2020
  10. Torsten BögershausenAug 7, 2020

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.