Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.posix.futimens() and related functions should take an optional pointer for "times" #22194

Open
mkauf opened this issue Dec 9, 2024 · 0 comments · May be fixed by #22248
Open

std.posix.futimens() and related functions should take an optional pointer for "times" #22194

mkauf opened this issue Dec 9, 2024 · 0 comments · May be fixed by #22248
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@mkauf
Copy link

mkauf commented Dec 9, 2024

Zig Version

0.14.0-dev.2384+cbc05e0b1

Steps to Reproduce and Observed Behavior

It should be possible to call std.posix.futimens() with a null pointer for times. This means that the current time must be used.

These related functions should also take an optional pointer for times:

  • c.futimes()
  • c.futimens()
  • c.utimes()
  • c.utimensat()

Example program:

const std = @import("std");

pub fn main() !void {
    const fd = try std.posix.open("test.txt", std.posix.O{ .CREAT = true, .ACCMODE = .WRONLY }, 0o644);
    defer std.posix.close(fd);

    try std.posix.futimens(fd, null);
}

The program does not build:

bug-report.zig:7:32: error: expected type '*const [2]os.linux.timespec__struct_1951', found '@TypeOf(null)'
    try std.posix.futimens(fd, null);
                               ^~~~
/usr/local/zig/lib/std/posix.zig:5760:34: note: parameter type declared here
pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void {
                                 ^~~~~~~~~~~~~~~~~~

Expected Behavior

The example program should build and run successfully.

@mkauf mkauf added the bug Observed behavior contradicts documented or intended behavior label Dec 9, 2024
@alexrp alexrp added standard library This issue involves writing Zig code for the standard library. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. labels Dec 9, 2024
@alexrp alexrp added this to the 0.15.0 milestone Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants