aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-01-31 10:04:44 +0000
committerLewis Russell <lewis6991@gmail.com>2023-01-31 17:18:57 +0000
commit33a183e8981de7894968a0d2aef836d9296786a7 (patch)
treea0218d5b70d51caad97db2569f1300fb40e3e89a
parenteacdece35426ce6e929fdd44d4ea331dc8317ea4 (diff)
downloadrneovim-33a183e8981de7894968a0d2aef836d9296786a7.tar.gz
rneovim-33a183e8981de7894968a0d2aef836d9296786a7.tar.bz2
rneovim-33a183e8981de7894968a0d2aef836d9296786a7.zip
refactor(fileio.c): make unreadable expression readable
-rw-r--r--src/nvim/fileio.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index cad48aee52..098db6b4af 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -3090,14 +3090,12 @@ nobackup:
// quotum for number of files).
// Appending will fail if the file does not exist and forceit is
// false.
- while ((fd = os_open(wfname,
- O_WRONLY |
- (append
- ? (forceit
- ? (O_APPEND | O_CREAT)
- : O_APPEND)
- : (O_CREAT | O_TRUNC)),
- perm < 0 ? 0666 : (perm & 0777))) < 0) {
+ const int fflags = O_WRONLY | (append
+ ? (forceit ? (O_APPEND | O_CREAT) : O_APPEND)
+ : (O_CREAT | O_TRUNC));
+ const int mode = perm < 0 ? 0666 : (perm & 0777);
+
+ while ((fd = os_open(wfname, fflags, mode)) < 0) {
// A forced write will try to create a new file if the old one
// is still readonly. This may also happen when the directory
// is read-only. In that case the mch_remove() will fail.