Merge pull request #8723 from jedisct1/init-stat

Initialize the Stat structure
This commit is contained in:
Jakub Konka 2021-05-10 09:42:37 +02:00 committed by GitHub
commit 9c03b39d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View File

@ -3408,7 +3408,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat {
@compileError("fstat is not yet implemented on Windows");
}
var stat: Stat = undefined;
var stat = mem.zeroes(Stat);
switch (errno(system.fstat(fd, &stat))) {
0 => return stat,
EINVAL => unreachable,
@ -3459,7 +3459,7 @@ pub fn fstatatWasi(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!S
/// Same as `fstatat` but `pathname` is null-terminated.
/// See also `fstatat`.
pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!Stat {
var stat: Stat = undefined;
var stat = mem.zeroes(Stat);
switch (errno(system.fstatat(dirfd, pathname, &stat, flags))) {
0 => return stat,
EINVAL => unreachable,

View File

@ -263,10 +263,6 @@ test "linkat with different directories" {
test "fstatat" {
// enable when `fstat` and `fstatat` are implemented on Windows
if (builtin.os.tag == .windows) return error.SkipZigTest;
if (builtin.os.tag == .freebsd and builtin.mode == .ReleaseFast) {
// https://github.com/ziglang/zig/issues/8538
return error.SkipZigTest;
}
var tmp = tmpDir(.{});
defer tmp.cleanup();