{"thread":{"id":"49891","subject":"[PATCH] setup.c: remove needless argument passed to open in sanitize_stdfds","startedAt":"2018-11-25T16:20:30Z","lastAt":"2018-11-26T04:39:14Z","messageCount":2,"participants":["pedrodelyra@gmail.com","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"364036","messageId":"20181125162008.30065-1-pedrodelyra@gmail.com","threadId":"49891","inReplyTo":null,"subject":"[PATCH] setup.c: remove needless argument passed to open in sanitize_stdfds","fromName":"","fromEmail":"pedrodelyra@gmail.com","sentAt":"2018-11-25T16:20:08Z","receivedAt":"2018-11-25T16:20:30Z","isPatch":true,"sender":{"key":"pedrodelyra@gmail.com","avatar":null},"body":"From: Pedro de Lyra <pedrodelyra@gmail.com>\n\nSigned-off-by: Pedro de Lyra <pedrodelyra@gmail.com>\n---\nAccording to POSIX manual pages, the open() system call's mode argument specifies the file mode bits to be applied when a new file is created. If neither O_CREAT nor O_TMPFILE is specified, then mode is ignored. So I guess that 0 argument only confuses the reader.\n setup.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/setup.c b/setup.c\nindex 1be5037f1..d4fd14bb7 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -1228,7 +1228,7 @@ const char *resolve_gitdir_gently(const char *suspect, int *return_error_code)\n /* if any standard file descriptor is missing open it to /dev/null */\n void sanitize_stdfds(void)\n {\n-\tint fd = open(\"/dev/null\", O_RDWR, 0);\n+\tint fd = open(\"/dev/null\", O_RDWR);\n \twhile (fd != -1 && fd < 2)\n \t\tfd = dup(fd);\n \tif (fd == -1)\n-- \n2.17.1\n\n"},{"id":"364051","messageId":"xmqqmupwzc47.fsf@gitster-ct.c.googlers.com","threadId":"49891","inReplyTo":"20181125162008.30065-1-pedrodelyra@gmail.com","subject":"Re: [PATCH] setup.c: remove needless argument passed to open in sanitize_stdfds","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-26T04:39:04Z","receivedAt":"2018-11-26T04:39:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"pedrodelyra@gmail.com writes:\n\n> According to POSIX manual pages, the open() system call's mode\n> argument specifies the file mode bits to be applied when a new\n> file is created. If neither O_CREAT nor O_TMPFILE is specified,\n> then mode is ignored.\n\nCorrect.  \n\nWhile I would say two argument form would have been better if this\nwere a new code, this change is borderline Meh for existing code,\nbecause passing 0 there already gives a reasonable sign that we know\nthis parameter does not matter.\n\nIf the ignored parameter were 0666 or some other more\nplausible-as-perm-bits value, the story would be quite different,\nthough.\n\nThanks.\n\n"}]}