git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] setup.c: remove needless argument passed to open in sanitize_stdfds
@ 2018-11-25 16:20 pedrodelyra
  2018-11-26  4:39 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: pedrodelyra @ 2018-11-25 16:20 UTC (permalink / raw)
  To: git; +Cc: Pedro de Lyra

From: Pedro de Lyra <pedrodelyra@gmail.com>

Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
---
According 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.
 setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.c b/setup.c
index 1be5037f1..d4fd14bb7 100644
--- a/setup.c
+++ b/setup.c
@@ -1228,7 +1228,7 @@ const char *resolve_gitdir_gently(const char *suspect, int *return_error_code)
 /* if any standard file descriptor is missing open it to /dev/null */
 void sanitize_stdfds(void)
 {
-	int fd = open("/dev/null", O_RDWR, 0);
+	int fd = open("/dev/null", O_RDWR);
 	while (fd != -1 && fd < 2)
 		fd = dup(fd);
 	if (fd == -1)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] setup.c: remove needless argument passed to open in sanitize_stdfds
  2018-11-25 16:20 [PATCH] setup.c: remove needless argument passed to open in sanitize_stdfds pedrodelyra
@ 2018-11-26  4:39 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2018-11-26  4:39 UTC (permalink / raw)
  To: pedrodelyra; +Cc: git

pedrodelyra@gmail.com writes:

> According 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.

Correct.  

While I would say two argument form would have been better if this
were a new code, this change is borderline Meh for existing code,
because passing 0 there already gives a reasonable sign that we know
this parameter does not matter.

If the ignored parameter were 0666 or some other more
plausible-as-perm-bits value, the story would be quite different,
though.

Thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-26  4:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-25 16:20 [PATCH] setup.c: remove needless argument passed to open in sanitize_stdfds pedrodelyra
2018-11-26  4:39 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).