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

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

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Aug 7, 2020, 00:01 UTC
Message-ID
<20200807000126.GC8085@camp.crustytoothpaste.net>
In-Reply-To
<xmqqy2mribft.fsf@gitster.c.googlers.com>
On 2020-08-06 at 23:47:34, Junio C Hamano wrote:
Show 11 quoted lines
> 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.

Yes, this seems like a prudent approach. I believe it's widely used by the Linux kernel, so presumably compilers are capable enough to optimize it out. As you noted, it provides type checking for all platforms, which is nice.

-- 
brian m. carlson: Houston, Texas, US
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 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.