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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 13, 2021 at 11:22:49AM -0700, Junio C Hamano wrote:

> Han-Wen Nienhuys <hanwen@xxxxxxxxxx> writes:
> 
> > On Thu, Sep 9, 2021 at 11:46 PM René Scharfe <l.s.r@xxxxxx> 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, ...);

Yes, you can see some examples (complete with interesting subtleties) in
wrapper.c:xopen() and compat/open.c:git_open_with_retry(). :)

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux