diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 93563bb245..0a368f9e26 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -189,11 +189,8 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void { .linux => if (use_pthreads) { if (self.getHandle() == std.c.pthread_self()) { // Set the name of the calling thread (no thread id required). - const err = try posix.prctl(.SET_NAME, .{@intFromPtr(name_with_terminator.ptr)}); - switch (@as(posix.E, @enumFromInt(err))) { - .SUCCESS => return, - else => |e| return posix.unexpectedErrno(e), - } + assert(try posix.prctl(.SET_NAME, .{@intFromPtr(name_with_terminator.ptr)}) == 0); + return; } else { const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr); switch (@as(posix.E, @enumFromInt(err))) { @@ -303,11 +300,8 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co .linux => if (use_pthreads) { if (self.getHandle() == std.c.pthread_self()) { // Get the name of the calling thread (no thread id required). - const err = try posix.prctl(.GET_NAME, .{@intFromPtr(buffer.ptr)}); - switch (@as(posix.E, @enumFromInt(err))) { - .SUCCESS => return std.mem.sliceTo(buffer, 0), - else => |e| return posix.unexpectedErrno(e), - } + assert(try posix.prctl(.GET_NAME, .{@intFromPtr(buffer.ptr)}) == 0); + return std.mem.sliceTo(buffer, 0); } else { const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); switch (@as(posix.E, @enumFromInt(err))) {