Commit 49886d2e45

LeRoyce Pearson <leroycepearson@geemili.xyz>
2020-04-07 06:07:27
Remove return value from os.flock()
1 parent 798207e
Changed files (2)
lib
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 };
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