diff --git a/lib/std/fs.zig b/lib/std/fs.zig index bd000c9693..c11ac74850 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -619,7 +619,7 @@ pub const Dir = struct { if (flags.lock and lock_flag == 0) { // TODO: integrate async I/O - _ = try os.flock(fd, if (flags.write) os.LOCK_EX else os.LOCK_SH); + try os.flock(fd, if (flags.write) os.LOCK_EX else os.LOCK_SH); } return File{ @@ -689,8 +689,7 @@ pub const Dir = struct { if (flags.lock and lock_flag == 0) { // TODO: integrate async I/O - // mem.zeroes is used here because flock's structure can vary across architectures and systems - _ = try os.flock(fd, os.LOCK_EX); + try os.flock(fd, os.LOCK_EX); } return File{ .handle = fd, .io_mode = .blocking }; diff --git a/lib/std/os.zig b/lib/std/os.zig index 1df22b0456..ec05a4a68a 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -3229,11 +3229,11 @@ pub const FlockError = error{ SystemResources, } || UnexpectedError; -pub fn flock(fd: fd_t, operation: i32) FlockError!usize { +pub fn flock(fd: fd_t, operation: i32) FlockError!void { while (true) { const rc = system.flock(fd, operation); switch (errno(rc)) { - 0 => return @intCast(usize, rc), + 0 => return, EBADF => unreachable, EINTR => continue, EINVAL => unreachable, // invalid parameters