refs/files-backend: remove unused open mode parameter
PATCH 1/1 refs/files-backend: remove unused open mode parameter
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.
--- refs/files-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
refs/files-backend.c +1 -1
@@ -1569,7 +1569,7 @@ static int log_ref_setup(struct files_ref_store *refs, goto error; } }else { - *logfd =open (logfile,O_APPEND |O_WRONLY ,0666 ); + *logfd =open (logfile,O_APPEND |O_WRONLY );if (*logfd <0 ) {if (errno ==ENOENT || errno ==EISDIR ) {/*
--
2.33.0
Quoted 2 lines · René Scharfe
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.
Obviously correct.
$ git grep -e 'open.*0[0-7][0-7][0-7]' seen \*.c | grep -v CREAT
gives this one and another from reftable.
-- >8 --
Subject: [PATCH] fixup! reftable: implement stack, a mutable database of reftable files.
To be squashed into the said commit.
--- reftable/stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
reftable/stack.c +1 -1
@@ -107,7 +107,7 @@ static int fd_read_lines(int fd, char ***namesp)int read_lines (const char *filename,char ***namesp) { -int fd =open (filename,O_RDONLY ,0644 ); +int fd =open (filename,O_RDONLY );int err =0 ;if (fd <0 ) {if (errno ==ENOENT ) {
Signature · 1 line
2.33.0-484-g4fa4683b52
Quoted 3 lines · René Scharfe
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.
LGTM
Signature · 7 lines
Han-Wen Nienhuys - Google Munich I work 80%. Don't expect answers from me on Fridays. -- Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Quoted 7 lines · Han-Wen Nienhuys
Quoted 3 lines · René Scharfe
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, ...);
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Han-Wen Nienhuys
Quoted 3 lines · René Scharfe
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.
Quoted 8 lines
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_tout ofva_listor 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