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...@@ -80,11 +80,11 @@ pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: u
80pub const posix_spawnattr_t = *opaque {};80pub const posix_spawnattr_t = *opaque {};
81pub const posix_spawn_file_actions_t = *opaque {};81pub const posix_spawn_file_actions_t = *opaque {};
82pub extern "c" fn posix_spawnattr_init(attr: *posix_spawnattr_t) c_int;82pub 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;
84pub extern "c" fn posix_spawnattr_setflags(attr: *posix_spawnattr_t, flags: c_short) c_int;84pub extern "c" fn posix_spawnattr_setflags(attr: *posix_spawnattr_t, flags: c_short) c_int;
85pub extern "c" fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *c_short) c_int;85pub extern "c" fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *c_short) c_int;
86pub extern "c" fn posix_spawn_file_actions_init(actions: *posix_spawn_file_actions_t) c_int;86pub 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;
88pub extern "c" fn posix_spawn_file_actions_addclose(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int;88pub extern "c" fn posix_spawn_file_actions_addclose(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int;
89pub extern "c" fn posix_spawn_file_actions_addopen(89pub extern "c" fn posix_spawn_file_actions_addopen(
90 actions: *posix_spawn_file_actions_t,90 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 {...@@ -47,8 +47,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {
47 }47 }
4848
49 pub fn deinit(self: *Attr) void {49 pub fn deinit(self: *Attr) void {
50 system.posix_spawnattr_destroy(&self.attr);50 defer self.* = undefined;
51 self.* = undefined;51 switch (errno(system.posix_spawnattr_destroy(&self.attr))) {
52 .SUCCESS => return,
53 .INVAL => unreachable, // Invalid parameters.
54 else => unreachable,
55 }
52 }56 }
5357
54 pub fn get(self: Attr) Error!u16 {58 pub fn get(self: Attr) Error!u16 {
...@@ -83,8 +87,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {...@@ -83,8 +87,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {
83 }87 }
8488
85 pub fn deinit(self: *Actions) void {89 pub fn deinit(self: *Actions) void {
86 system.posix_spawn_file_actions_destroy(&self.actions);90 defer self.* = undefined;
87 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 }
88 }96 }
8997
90 pub fn open(self: *Actions, fd: fd_t, path: []const u8, flags: u32, mode: mode_t) Error!void {98 pub fn open(self: *Actions, fd: fd_t, path: []const u8, flags: u32, mode: mode_t) Error!void {