Commit 3eb93f3c8683453016417c3a4a8a989c7afadcdb

Stefan Sperling 2019-04-11T13:39:11

inline open(2) flags in got_lockfile_lock()

diff --git a/lib/lockfile.c b/lib/lockfile.c
index 97ae4bc..dc493f7 100644
--- a/lib/lockfile.c
+++ b/lib/lockfile.c
@@ -34,7 +34,6 @@ const struct got_error *
 got_lockfile_lock(struct got_lockfile **lf, const char *path)
 {
 	const struct got_error *err = NULL;
-	const int flags = O_RDONLY | O_CREAT | O_EXCL | O_EXLOCK;
 	int attempts = 5;
 
 	*lf = calloc(1, sizeof(**lf));
@@ -54,7 +53,9 @@ got_lockfile_lock(struct got_lockfile **lf, const char *path)
 	}
 
 	do {
-		(*lf)->fd = open((*lf)->path, flags, GOT_DEFAULT_FILE_MODE);
+		(*lf)->fd = open((*lf)->path,
+		    O_RDONLY | O_CREAT | O_EXCL | O_EXLOCK,
+		    GOT_DEFAULT_FILE_MODE);
 		if ((*lf)->fd != -1)
 			break;
 		if (errno != EEXIST) {