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

Re: [PATCH] refs/files-backend: remove unused open mode parameter

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 13, 2021, 18:22 UTC
Message-ID
<xmqqilz4fi86.fsf@gitster.g>
In-Reply-To
<CAFQ2z_NAXsOzbWujpm=jGxODJi+xsC9iFYd-W+dTqn9j5DybjQ@mail.gmail.com>
Han-Wen Nienhuys <hanwen@google.com> writes:
Show 7 quoted lines
> On Thu, Sep 9, 2021 at 11:46 PM René Scharfe <l.s.r@web.de> wrote:
>>
>> We only need to provide a mode if we are willing to let open(2) create
>> the file, which is not the case here, so drop the unnecessary parameter.
>
> I was #today years old when I learned that C supports (a limited form
> of) function signature overloading.
I do not think it is that kind of magic.

Like printf(3) that allows its early parameter to affect the way how its later parameters are recognised, it just allows the flags word to decide if it needs to grab one extra mode_t out of va_list or not, which can be done as a plain vanilla varargs function, i.e.

	extern int open(const char *path, int flags, ...);
Previous: Han-Wen NienhuysNext: Jeff King
Message 4 of 5 in “refs/files-backend: remove unused open mode parameter”
  1. refs/files-backend: remove unused open mode parameterRené Scharfe, Sep 9, 2021
  2. Junio C HamanoSep 10, 2021
  3. Han-Wen NienhuysSep 13, 2021
  4. Junio C HamanoSep 13, 2021
  5. Jeff KingSep 13, 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.