{"thread":{"id":"56475","subject":"[PATCH] refs/files-backend: remove unused open mode parameter","startedAt":"2021-09-09T21:46:00Z","lastAt":"2021-09-13T19:03:16Z","messageCount":5,"participants":["René Scharfe","Junio C Hamano","Han-Wen Nienhuys","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"435339","messageId":"ea424e3d-6269-f50d-1a4a-643bb95cfa12@web.de","threadId":"56475","inReplyTo":null,"subject":"[PATCH] refs/files-backend: remove unused open mode parameter","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2021-09-09T21:45:51Z","receivedAt":"2021-09-09T21:46:00Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"We only need to provide a mode if we are willing to let open(2) create\nthe file, which is not the case here, so drop the unnecessary parameter.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n refs/files-backend.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 677b7e4cdd..74c0385873 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -1569,7 +1569,7 @@ static int log_ref_setup(struct files_ref_store *refs,\n \t\t\tgoto error;\n \t\t}\n \t} else {\n-\t\t*logfd = open(logfile, O_APPEND | O_WRONLY, 0666);\n+\t\t*logfd = open(logfile, O_APPEND | O_WRONLY);\n \t\tif (*logfd < 0) {\n \t\t\tif (errno == ENOENT || errno == EISDIR) {\n \t\t\t\t/*\n--\n2.33.0\n"},{"id":"435361","messageId":"xmqqee9xw96b.fsf@gitster.g","threadId":"56475","inReplyTo":"ea424e3d-6269-f50d-1a4a-643bb95cfa12@web.de","subject":"Re: [PATCH] refs/files-backend: remove unused open mode parameter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-09-10T00:45:00Z","receivedAt":"2021-09-10T00:47:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> We only need to provide a mode if we are willing to let open(2) create\n> the file, which is not the case here, so drop the unnecessary parameter.\n\nObviously correct.\n\n$ git grep -e 'open.*0[0-7][0-7][0-7]' seen \\*.c | grep -v CREAT\n\ngives this one and another from reftable.\n\n-- >8 --\nSubject: [PATCH] fixup! reftable: implement stack, a mutable database of reftable files.\n\nTo be squashed into the said commit.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n reftable/stack.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/reftable/stack.c b/reftable/stack.c\nindex 48e22a6c18..df5021ebf0 100644\n--- a/reftable/stack.c\n+++ b/reftable/stack.c\n@@ -107,7 +107,7 @@ static int fd_read_lines(int fd, char ***namesp)\n \n int read_lines(const char *filename, char ***namesp)\n {\n-\tint fd = open(filename, O_RDONLY, 0644);\n+\tint fd = open(filename, O_RDONLY);\n \tint err = 0;\n \tif (fd < 0) {\n \t\tif (errno == ENOENT) {\n-- \n2.33.0-484-g4fa4683b52\n\n\n\n"},{"id":"435700","messageId":"CAFQ2z_NAXsOzbWujpm=jGxODJi+xsC9iFYd-W+dTqn9j5DybjQ@mail.gmail.com","threadId":"56475","inReplyTo":"ea424e3d-6269-f50d-1a4a-643bb95cfa12@web.de","subject":"Re: [PATCH] refs/files-backend: remove unused open mode parameter","fromName":"Han-Wen Nienhuys","fromEmail":"hanwen@google.com","sentAt":"2021-09-13T10:12:03Z","receivedAt":"2021-09-13T10:12:17Z","isPatch":true,"sender":{"key":"hanwen@google.com","avatar":"https://avatars.githubusercontent.com/u/31547?v=4"},"body":"On Thu, Sep 9, 2021 at 11:46 PM René Scharfe <l.s.r@web.de> wrote:\n>\n> We only need to provide a mode if we are willing to let open(2) create\n> the file, which is not the case here, so drop the unnecessary parameter.\n\nI was #today years old when I learned that C supports (a limited form\nof) function signature overloading.\n\nLGTM\n\n-- \nHan-Wen Nienhuys - Google Munich\nI work 80%. Don't expect answers from me on Fridays.\n--\nGoogle Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich\nRegistergericht und -nummer: Hamburg, HRB 86891\nSitz der Gesellschaft: Hamburg\nGeschäftsführer: Paul Manicle, Halimah DeLaine Prado\n"},{"id":"435765","messageId":"xmqqilz4fi86.fsf@gitster.g","threadId":"56475","inReplyTo":"CAFQ2z_NAXsOzbWujpm=jGxODJi+xsC9iFYd-W+dTqn9j5DybjQ@mail.gmail.com","subject":"Re: [PATCH] refs/files-backend: remove unused open mode parameter","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-09-13T18:22:49Z","receivedAt":"2021-09-13T18:22:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Han-Wen Nienhuys <hanwen@google.com> writes:\n\n> On Thu, Sep 9, 2021 at 11:46 PM René Scharfe <l.s.r@web.de> wrote:\n>>\n>> We only need to provide a mode if we are willing to let open(2) create\n>> the file, which is not the case here, so drop the unnecessary parameter.\n>\n> I was #today years old when I learned that C supports (a limited form\n> of) function signature overloading.\n\nI do not think it is that kind of magic.\n\nLike printf(3) that allows its early parameter to affect the way how\nits later parameters are recognised, it just allows the flags word\nto decide if it needs to grab one extra mode_t out of va_list or\nnot, which can be done as a plain vanilla varargs function, i.e.\n\n\textern int open(const char *path, int flags, ...);\n\n"},{"id":"435768","messageId":"YT+gbhnKmd0nlpxG@coredump.intra.peff.net","threadId":"56475","inReplyTo":"xmqqilz4fi86.fsf@gitster.g","subject":"Re: [PATCH] refs/files-backend: remove unused open mode parameter","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-09-13T19:03:10Z","receivedAt":"2021-09-13T19:03:16Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Sep 13, 2021 at 11:22:49AM -0700, Junio C Hamano wrote:\n\n> Han-Wen Nienhuys <hanwen@google.com> writes:\n> \n> > On Thu, Sep 9, 2021 at 11:46 PM René Scharfe <l.s.r@web.de> wrote:\n> >>\n> >> We only need to provide a mode if we are willing to let open(2) create\n> >> the file, which is not the case here, so drop the unnecessary parameter.\n> >\n> > I was #today years old when I learned that C supports (a limited form\n> > of) function signature overloading.\n> \n> I do not think it is that kind of magic.\n> \n> Like printf(3) that allows its early parameter to affect the way how\n> its later parameters are recognised, it just allows the flags word\n> to decide if it needs to grab one extra mode_t out of va_list or\n> not, which can be done as a plain vanilla varargs function, i.e.\n> \n> \textern int open(const char *path, int flags, ...);\n\nYes, you can see some examples (complete with interesting subtleties) in\nwrapper.c:xopen() and compat/open.c:git_open_with_retry(). :)\n\n-Peff\n"}]}