authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2022-09-28 20:21:33+03:30
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-13 13:21:19+02:00
logfb366f3cd4a8a28a2a66753acc53d06a0d88c838
tree4243467d2c6b4caeb4b87635014b77349bbcc072
parent6af0eeb58d1d220d407ce4c463eaeb25b35f2761

std.c: fix incorrect return types

Closes #12964

2 files changed, 14 insertions(+), 6 deletions(-)

lib/std/c/darwin.zig+2-2
......@@ -80,11 +80,11 @@ pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: u
8080pub const posix_spawnattr_t = *opaque {};
8181pub const posix_spawn_file_actions_t = *opaque {};
8282pub extern "c" fn posix_spawnattr_init(attr: *posix_spawnattr_t) c_int;
83pub extern "c" fn posix_spawnattr_destroy(attr: *posix_spawnattr_t) void;
83pub extern "c" fn posix_spawnattr_destroy(attr: *posix_spawnattr_t) c_int;
8484pub extern "c" fn posix_spawnattr_setflags(attr: *posix_spawnattr_t, flags: c_short) c_int;
8585pub extern "c" fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *c_short) c_int;
8686pub extern "c" fn posix_spawn_file_actions_init(actions: *posix_spawn_file_actions_t) c_int;
87pub extern "c" fn posix_spawn_file_actions_destroy(actions: *posix_spawn_file_actions_t) void;
87pub extern "c" fn posix_spawn_file_actions_destroy(actions: *posix_spawn_file_actions_t) c_int;
8888pub extern "c" fn posix_spawn_file_actions_addclose(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int;
8989pub extern "c" fn posix_spawn_file_actions_addopen(
9090 actions: *posix_spawn_file_actions_t,
lib/std/os/posix_spawn.zig+12-4
......@@ -47,8 +47,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {
4747 }
4848
4949 pub fn deinit(self: *Attr) void {
50 system.posix_spawnattr_destroy(&self.attr);
51 self.* = undefined;
50 defer self.* = undefined;
51 switch (errno(system.posix_spawnattr_destroy(&self.attr))) {
52 .SUCCESS => return,
53 .INVAL => unreachable, // Invalid parameters.
54 else => unreachable,
55 }
5256 }
5357
5458 pub fn get(self: Attr) Error!u16 {
......@@ -83,8 +87,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {
8387 }
8488
8589 pub fn deinit(self: *Actions) void {
86 system.posix_spawn_file_actions_destroy(&self.actions);
87 self.* = undefined;
90 defer self.* = undefined;
91 switch (errno(system.posix_spawn_file_actions_destroy(&self.actions))) {
92 .SUCCESS => return,
93 .INVAL => unreachable, // Invalid parameters.
94 else => unreachable,
95 }
8896 }
8997
9098 pub fn open(self: *Actions, fd: fd_t, path: []const u8, flags: u32, mode: mode_t) Error!void {