Skip to content

Commit

Permalink
Replace @truncate with @intcast
Browse files Browse the repository at this point in the history
This should be safe because `uid_t` will be 32-bit.
  • Loading branch information
Andreas Linz committed Dec 17, 2020
1 parent e885958 commit 7999628
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/std/os/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -745,33 +745,33 @@ pub fn setregid(rgid: gid_t, egid: gid_t) usize {

pub fn getuid() uid_t {
if (@hasField(SYS, "getuid32")) {
return @truncate(uid_t, syscall0(.getuid32));
return @intCast(uid_t, syscall0(.getuid32));
} else {
return @truncate(uid_t, syscall0(.getuid));
return @intCast(uid_t, syscall0(.getuid));
}
}

pub fn getgid() gid_t {
if (@hasField(SYS, "getgid32")) {
return @truncate(gid_t, syscall0(.getgid32));
return @intCast(gid_t, syscall0(.getgid32));
} else {
return @truncate(gid_t, syscall0(.getgid));
return @intCast(gid_t, syscall0(.getgid));
}
}

pub fn geteuid() uid_t {
if (@hasField(SYS, "geteuid32")) {
return @truncate(uid_t, syscall0(.geteuid32));
return @intCast(uid_t, syscall0(.geteuid32));
} else {
return @truncate(uid_t, syscall0(.geteuid));
return @intCast(uid_t, syscall0(.geteuid));
}
}

pub fn getegid() gid_t {
if (@hasField(SYS, "getegid32")) {
return @truncate(gid_t, syscall0(.getegid32));
return @intCast(gid_t, syscall0(.getegid32));
} else {
return @truncate(gid_t, syscall0(.getegid));
return @intCast(gid_t, syscall0(.getegid));
}
}

Expand Down

0 comments on commit 7999628

Please sign in to comment.