bump to zig 0.11.0-dev.3735+a72d634b7
This commit is contained in:
parent
f723d48fe2
commit
ff0f5bca77
|
@ -33,7 +33,7 @@ Project goals
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
1. zig around `0.11.0-dev.3312+ab37ab33c`.
|
1. zig around `0.11.0-dev.3735+a72d634b7`.
|
||||||
2. [cmph][cmph]: bundled with this repository.
|
2. [cmph][cmph]: bundled with this repository.
|
||||||
|
|
||||||
Building
|
Building
|
||||||
|
|
|
@ -155,7 +155,7 @@ pub fn build(b: *zbs.Builder) void {
|
||||||
const so = b.addSharedLibrary(.{
|
const so = b.addSharedLibrary(.{
|
||||||
.name = "nss_turbo",
|
.name = "nss_turbo",
|
||||||
.root_source_file = .{ .path = "src/libnss.zig" },
|
.root_source_file = .{ .path = "src/libnss.zig" },
|
||||||
.version = builtin.Version{
|
.version = std.SemanticVersion{
|
||||||
.major = 2,
|
.major = 2,
|
||||||
.minor = 0,
|
.minor = 0,
|
||||||
.patch = 0,
|
.patch = 0,
|
||||||
|
|
|
@ -95,7 +95,7 @@ pub fn init(
|
||||||
for (name_idx) |entry| {
|
for (name_idx) |entry| {
|
||||||
const user = try usersConst[entry.idx].clone(allocator);
|
const user = try usersConst[entry.idx].clone(allocator);
|
||||||
users.appendAssumeCapacity(user);
|
users.appendAssumeCapacity(user);
|
||||||
getpw_bufsize = math.max(getpw_bufsize, user.strlenZ());
|
getpw_bufsize = @max(getpw_bufsize, user.strlenZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ pub fn init(
|
||||||
for (gid_idx) |entry| {
|
for (gid_idx) |entry| {
|
||||||
const group = try groupsConst[entry.idx].clone(allocator);
|
const group = try groupsConst[entry.idx].clone(allocator);
|
||||||
groups.appendAssumeCapacity(group);
|
groups.appendAssumeCapacity(group);
|
||||||
getgr_bufsize = math.max(getgr_bufsize, group.strlenZ());
|
getgr_bufsize = @max(getgr_bufsize, group.strlenZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ pub fn iov(self: *align(8) const DB) BoundedArray(os.iovec_const, DB_fields.len
|
||||||
.iov_base = bytes.ptr,
|
.iov_base = bytes.ptr,
|
||||||
.iov_len = bytes.len,
|
.iov_len = bytes.len,
|
||||||
});
|
});
|
||||||
const padding = mem.alignForward(bytes.len, section_length) - bytes.len;
|
const padding = mem.alignForward(usize, bytes.len, section_length) - bytes.len;
|
||||||
if (padding != 0)
|
if (padding != 0)
|
||||||
result.appendAssumeCapacity(.{
|
result.appendAssumeCapacity(.{
|
||||||
.iov_base = zeroes,
|
.iov_base = zeroes,
|
||||||
|
@ -595,7 +595,7 @@ fn usersSection(
|
||||||
gids.idx2offset[i],
|
gids.idx2offset[i],
|
||||||
shells.shell2idx,
|
shells.shell2idx,
|
||||||
);
|
);
|
||||||
try blob.appendNTimes(0, mem.alignForward(blob.items.len, 8) - blob.items.len);
|
try blob.appendNTimes(0, mem.alignForward(usize, blob.items.len, 8) - blob.items.len);
|
||||||
}
|
}
|
||||||
return UsersSection{
|
return UsersSection{
|
||||||
.len = @intCast(u32, users.len),
|
.len = @intCast(u32, users.len),
|
||||||
|
@ -686,7 +686,7 @@ fn groupsSection(
|
||||||
.members_offset = members_offset_i,
|
.members_offset = members_offset_i,
|
||||||
};
|
};
|
||||||
try PackedGroup.packTo(&blob, group_stored);
|
try PackedGroup.packTo(&blob, group_stored);
|
||||||
try blob.appendNTimes(0, mem.alignForward(blob.items.len, 8) - blob.items.len);
|
try blob.appendNTimes(0, mem.alignForward(usize, blob.items.len, 8) - blob.items.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GroupsSection{
|
return GroupsSection{
|
||||||
|
@ -733,7 +733,7 @@ pub fn nblocks_n(comptime T: type, nbytes: usize) T {
|
||||||
u64 => u70,
|
u64 => u70,
|
||||||
else => @compileError("unsupported type " ++ @typeName(T)),
|
else => @compileError("unsupported type " ++ @typeName(T)),
|
||||||
};
|
};
|
||||||
const upper = @intCast(B, mem.alignForward(nbytes, section_length));
|
const upper = @intCast(B, mem.alignForward(usize, nbytes, section_length));
|
||||||
assert(upper & (section_length - 1) == 0);
|
assert(upper & (section_length - 1) == 0);
|
||||||
return @truncate(T, upper >> section_length_bits);
|
return @truncate(T, upper >> section_length_bits);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub fn write(self: *ErrCtx, bytes: []const u8) error{}!usize {
|
||||||
if (can_add == 0) return bytes.len;
|
if (can_add == 0) return bytes.len;
|
||||||
|
|
||||||
self.overflow = bytes.len > can_add;
|
self.overflow = bytes.len > can_add;
|
||||||
self.buf.appendSliceAssumeCapacity(bytes[0..math.min(bytes.len, can_add)]);
|
self.buf.appendSliceAssumeCapacity(bytes[0..@min(bytes.len, can_add)]);
|
||||||
// not adding the final zero is ok, because it will
|
// not adding the final zero is ok, because it will
|
||||||
// be ignored in the iterator anyway.
|
// be ignored in the iterator anyway.
|
||||||
_ = self.buf.append(0) catch null;
|
_ = self.buf.append(0) catch null;
|
||||||
|
@ -68,24 +68,24 @@ pub fn wrapf(self: *ErrCtx, comptime format: []const u8, args: anytype) *ErrCtx
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iterator(self: *const ErrCtx) mem.SplitIterator(u8) {
|
pub fn iterator(self: *const ErrCtx) mem.SplitIterator(u8, .scalar) {
|
||||||
const slice = self.buf.constSlice();
|
const slice = self.buf.constSlice();
|
||||||
const last_byte = if (slice[slice.len - 1] == 0) slice.len - 1 else slice.len;
|
const last_byte = if (slice[slice.len - 1] == 0) slice.len - 1 else slice.len;
|
||||||
return mem.split(u8, slice[0..last_byte], "\x00");
|
return mem.splitScalar(u8, slice[0..last_byte], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rev(self: *const ErrCtx) mem.SplitBackwardsIterator(u8) {
|
pub fn rev(self: *const ErrCtx) mem.SplitBackwardsIterator(u8, .scalar) {
|
||||||
const slice = self.buf.constSlice();
|
const slice = self.buf.constSlice();
|
||||||
if (slice.len == 0) {
|
if (slice.len == 0) {
|
||||||
return mem.SplitBackwardsIterator(u8){
|
return mem.SplitBackwardsIterator(u8, .scalar){
|
||||||
.buffer = slice,
|
.buffer = slice,
|
||||||
.index = null,
|
.index = null,
|
||||||
.delimiter = "\x00",
|
.delimiter = 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const last_byte = if (slice[slice.len - 1] == 0) (slice.len - 1) else slice.len;
|
const last_byte = if (slice[slice.len - 1] == 0) (slice.len - 1) else slice.len;
|
||||||
return mem.splitBackwards(u8, slice[0..last_byte], "\x00");
|
return mem.splitBackwardsScalar(u8, slice[0..last_byte], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap(self: *const ErrCtx) BoundedArray(u8, capacity * 2) {
|
pub fn unwrap(self: *const ErrCtx) BoundedArray(u8, capacity * 2) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub fn fromBytes(bytes: []align(8) const u8) error{Overflow}!Entry {
|
||||||
.groupdata = bytes[start_blob..end_strings],
|
.groupdata = bytes[start_blob..end_strings],
|
||||||
.members_offset = members_offset.value,
|
.members_offset = members_offset.value,
|
||||||
},
|
},
|
||||||
.end = mem.alignForward(end_blob, 8),
|
.end = mem.alignForward(usize, end_blob, 8),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ test "PackedGroup construct" {
|
||||||
|
|
||||||
for (groups) |group| {
|
for (groups) |group| {
|
||||||
try PackedGroup.packTo(&buf, group);
|
try PackedGroup.packTo(&buf, group);
|
||||||
try buf.appendNTimes(0, mem.alignForward(buf.items.len, 8) - buf.items.len);
|
try buf.appendNTimes(0, mem.alignForward(usize, buf.items.len, 8) - buf.items.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
var i: u29 = 0;
|
var i: u29 = 0;
|
||||||
|
|
|
@ -96,7 +96,7 @@ pub fn fromBytes(blob: []align(8) const u8) error{Overflow}!Entry {
|
||||||
.var_payload = blob[start_var_payload..end_payload],
|
.var_payload = blob[start_var_payload..end_payload],
|
||||||
.additional_gids_offset = gids_offset.value,
|
.additional_gids_offset = gids_offset.value,
|
||||||
},
|
},
|
||||||
.end = mem.alignForward(end_payload, 8),
|
.end = mem.alignForward(usize, end_payload, 8),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ test "PackedUser construct section" {
|
||||||
defer shellIndex.deinit();
|
defer shellIndex.deinit();
|
||||||
for (users) |user| {
|
for (users) |user| {
|
||||||
try PackedUser.packTo(&buf, user, additional_gids, shellIndex);
|
try PackedUser.packTo(&buf, user, additional_gids, shellIndex);
|
||||||
try buf.appendNTimes(0, mem.alignForward(buf.items.len, 8) - buf.items.len);
|
try buf.appendNTimes(0, mem.alignForward(usize, buf.items.len, 8) - buf.items.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
var i: u29 = 0;
|
var i: u29 = 0;
|
||||||
|
|
|
@ -142,13 +142,13 @@ fn getpwuid_r(
|
||||||
var cuser = db.getpwuid(uid, buffer[0..buflen]) catch |err| switch (err) {
|
var cuser = db.getpwuid(uid, buffer[0..buflen]) catch |err| switch (err) {
|
||||||
error.Overflow => return badFile(errnop),
|
error.Overflow => return badFile(errnop),
|
||||||
error.BufferTooSmall => {
|
error.BufferTooSmall => {
|
||||||
errnop.* = @enumToInt(os.E.RANGE);
|
errnop.* = @intFromEnum(os.E.RANGE);
|
||||||
return c.NSS_STATUS_TRYAGAIN;
|
return c.NSS_STATUS_TRYAGAIN;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const got_cuser = cuser orelse {
|
const got_cuser = cuser orelse {
|
||||||
errnop.* = @enumToInt(os.E.NOENT);
|
errnop.* = @intFromEnum(os.E.NOENT);
|
||||||
return c.NSS_STATUS_NOTFOUND;
|
return c.NSS_STATUS_NOTFOUND;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -181,13 +181,13 @@ fn getpwnam_r(
|
||||||
const cuser = db.getpwnam(nameSlice, buf) catch |err| switch (err) {
|
const cuser = db.getpwnam(nameSlice, buf) catch |err| switch (err) {
|
||||||
error.Overflow => return badFile(errnop),
|
error.Overflow => return badFile(errnop),
|
||||||
error.BufferTooSmall => {
|
error.BufferTooSmall => {
|
||||||
errnop.* = @enumToInt(os.E.RANGE);
|
errnop.* = @intFromEnum(os.E.RANGE);
|
||||||
return c.NSS_STATUS_TRYAGAIN;
|
return c.NSS_STATUS_TRYAGAIN;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const got_cuser = cuser orelse {
|
const got_cuser = cuser orelse {
|
||||||
errnop.* = @enumToInt(os.E.NOENT);
|
errnop.* = @intFromEnum(os.E.NOENT);
|
||||||
return c.NSS_STATUS_NOTFOUND;
|
return c.NSS_STATUS_NOTFOUND;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ export fn _nss_turbo_getgrgid_r(
|
||||||
) c.enum_nss_status {
|
) c.enum_nss_status {
|
||||||
global_init.call();
|
global_init.call();
|
||||||
var state = &(global_state orelse {
|
var state = &(global_state orelse {
|
||||||
errnop.* = @enumToInt(os.E.AGAIN);
|
errnop.* = @intFromEnum(os.E.AGAIN);
|
||||||
return c.NSS_STATUS_UNAVAIL;
|
return c.NSS_STATUS_UNAVAIL;
|
||||||
});
|
});
|
||||||
return getgrgid_r(state, gid, gr, buffer, buflen, errnop);
|
return getgrgid_r(state, gid, gr, buffer, buflen, errnop);
|
||||||
|
@ -225,13 +225,13 @@ fn getgrgid_r(
|
||||||
const cgroup = db.getgrgid(gid, buf, omit_members) catch |err| switch (err) {
|
const cgroup = db.getgrgid(gid, buf, omit_members) catch |err| switch (err) {
|
||||||
error.Overflow => return badFile(errnop),
|
error.Overflow => return badFile(errnop),
|
||||||
error.BufferTooSmall => {
|
error.BufferTooSmall => {
|
||||||
errnop.* = @enumToInt(os.E.RANGE);
|
errnop.* = @intFromEnum(os.E.RANGE);
|
||||||
return c.NSS_STATUS_TRYAGAIN;
|
return c.NSS_STATUS_TRYAGAIN;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
gr.* = cgroup orelse {
|
gr.* = cgroup orelse {
|
||||||
errnop.* = @enumToInt(os.E.NOENT);
|
errnop.* = @intFromEnum(os.E.NOENT);
|
||||||
return c.NSS_STATUS_NOTFOUND;
|
return c.NSS_STATUS_NOTFOUND;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ export fn _nss_turbo_getgrnam_r(
|
||||||
) c.enum_nss_status {
|
) c.enum_nss_status {
|
||||||
global_init.call();
|
global_init.call();
|
||||||
var state = &(global_state orelse {
|
var state = &(global_state orelse {
|
||||||
errnop.* = @enumToInt(os.E.AGAIN);
|
errnop.* = @intFromEnum(os.E.AGAIN);
|
||||||
return c.NSS_STATUS_UNAVAIL;
|
return c.NSS_STATUS_UNAVAIL;
|
||||||
});
|
});
|
||||||
return getgrnam_r(state, name, group, buffer, buflen, errnop);
|
return getgrnam_r(state, name, group, buffer, buflen, errnop);
|
||||||
|
@ -268,12 +268,12 @@ fn getgrnam_r(
|
||||||
const cgroup = db.getgrnam(nameSlice, buf, omit_members) catch |err| switch (err) {
|
const cgroup = db.getgrnam(nameSlice, buf, omit_members) catch |err| switch (err) {
|
||||||
error.Overflow => return badFile(errnop),
|
error.Overflow => return badFile(errnop),
|
||||||
error.BufferTooSmall => {
|
error.BufferTooSmall => {
|
||||||
errnop.* = @enumToInt(os.E.RANGE);
|
errnop.* = @intFromEnum(os.E.RANGE);
|
||||||
return c.NSS_STATUS_TRYAGAIN;
|
return c.NSS_STATUS_TRYAGAIN;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
group.* = cgroup orelse {
|
group.* = cgroup orelse {
|
||||||
errnop.* = @enumToInt(os.E.NOENT);
|
errnop.* = @intFromEnum(os.E.NOENT);
|
||||||
return c.NSS_STATUS_NOTFOUND;
|
return c.NSS_STATUS_NOTFOUND;
|
||||||
};
|
};
|
||||||
return c.NSS_STATUS_SUCCESS;
|
return c.NSS_STATUS_SUCCESS;
|
||||||
|
@ -347,7 +347,7 @@ export fn _nss_turbo_getgrent_r(
|
||||||
) c.enum_nss_status {
|
) c.enum_nss_status {
|
||||||
global_init.call();
|
global_init.call();
|
||||||
var state = &(global_state orelse {
|
var state = &(global_state orelse {
|
||||||
errnop.* = @enumToInt(os.E.AGAIN);
|
errnop.* = @intFromEnum(os.E.AGAIN);
|
||||||
return c.NSS_STATUS_UNAVAIL;
|
return c.NSS_STATUS_UNAVAIL;
|
||||||
});
|
});
|
||||||
return getgrent_r(state, result, buffer, buflen, errnop);
|
return getgrent_r(state, result, buffer, buflen, errnop);
|
||||||
|
@ -365,7 +365,7 @@ fn getgrent_r(
|
||||||
|
|
||||||
var it = &(state.getgrent_iterator orelse {
|
var it = &(state.getgrent_iterator orelse {
|
||||||
// logic from _nss_systemd_getgrent_r
|
// logic from _nss_systemd_getgrent_r
|
||||||
errnop.* = @enumToInt(os.E.HOSTDOWN);
|
errnop.* = @intFromEnum(os.E.HOSTDOWN);
|
||||||
return c.NSS_STATUS_UNAVAIL;
|
return c.NSS_STATUS_UNAVAIL;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ fn getgrent_r(
|
||||||
},
|
},
|
||||||
error.BufferTooSmall => {
|
error.BufferTooSmall => {
|
||||||
it.rollback();
|
it.rollback();
|
||||||
errnop.* = @enumToInt(os.E.RANGE);
|
errnop.* = @intFromEnum(os.E.RANGE);
|
||||||
return c.NSS_STATUS_TRYAGAIN;
|
return c.NSS_STATUS_TRYAGAIN;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ export fn _nss_turbo_getpwent_r(
|
||||||
) c.enum_nss_status {
|
) c.enum_nss_status {
|
||||||
global_init.call();
|
global_init.call();
|
||||||
var state = &(global_state orelse {
|
var state = &(global_state orelse {
|
||||||
errnop.* = @enumToInt(os.E.AGAIN);
|
errnop.* = @intFromEnum(os.E.AGAIN);
|
||||||
return c.NSS_STATUS_UNAVAIL;
|
return c.NSS_STATUS_UNAVAIL;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ fn getpwent_r(
|
||||||
|
|
||||||
var it = &(state.getpwent_iterator orelse {
|
var it = &(state.getpwent_iterator orelse {
|
||||||
// logic from _nss_systemd_getgrent_r
|
// logic from _nss_systemd_getgrent_r
|
||||||
errnop.* = @enumToInt(os.E.HOSTDOWN);
|
errnop.* = @intFromEnum(os.E.HOSTDOWN);
|
||||||
return c.NSS_STATUS_UNAVAIL;
|
return c.NSS_STATUS_UNAVAIL;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ fn getpwent_r(
|
||||||
const cuser = state.file.db.writeUser(user, buf) catch |err| switch (err) {
|
const cuser = state.file.db.writeUser(user, buf) catch |err| switch (err) {
|
||||||
error.BufferTooSmall => {
|
error.BufferTooSmall => {
|
||||||
it.rollback();
|
it.rollback();
|
||||||
errnop.* = @enumToInt(os.E.RANGE);
|
errnop.* = @intFromEnum(os.E.RANGE);
|
||||||
return c.NSS_STATUS_TRYAGAIN;
|
return c.NSS_STATUS_TRYAGAIN;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -459,7 +459,7 @@ export fn _nss_turbo_initgroups_dyn(
|
||||||
) c.enum_nss_status {
|
) c.enum_nss_status {
|
||||||
global_init.call();
|
global_init.call();
|
||||||
var state = &(global_state orelse {
|
var state = &(global_state orelse {
|
||||||
errnop.* = @enumToInt(os.E.AGAIN);
|
errnop.* = @intFromEnum(os.E.AGAIN);
|
||||||
return c.NSS_STATUS_UNAVAIL;
|
return c.NSS_STATUS_UNAVAIL;
|
||||||
});
|
});
|
||||||
return initgroups_dyn(state, user_name, gid, start, size, groupsp, limit, errnop);
|
return initgroups_dyn(state, user_name, gid, start, size, groupsp, limit, errnop);
|
||||||
|
@ -479,7 +479,7 @@ fn initgroups_dyn(
|
||||||
const user = db.getUserByName(mem.sliceTo(user_name, 0)) catch |err| switch (err) {
|
const user = db.getUserByName(mem.sliceTo(user_name, 0)) catch |err| switch (err) {
|
||||||
error.Overflow => return badFile(errnop),
|
error.Overflow => return badFile(errnop),
|
||||||
} orelse {
|
} orelse {
|
||||||
errnop.* = @enumToInt(os.E.NOENT);
|
errnop.* = @intFromEnum(os.E.NOENT);
|
||||||
return c.NSS_STATUS_NOTFOUND;
|
return c.NSS_STATUS_NOTFOUND;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ fn initgroups_dyn(
|
||||||
const newsize: usize = if (limit <= 0)
|
const newsize: usize = if (limit <= 0)
|
||||||
newsize_want
|
newsize_want
|
||||||
else
|
else
|
||||||
math.min(@intCast(usize, limit), newsize_want);
|
@min(@intCast(usize, limit), newsize_want);
|
||||||
|
|
||||||
var buf = groupsp.*[0..oldsize];
|
var buf = groupsp.*[0..oldsize];
|
||||||
const new_groups = state.initgroups_dyn_allocator.realloc(
|
const new_groups = state.initgroups_dyn_allocator.realloc(
|
||||||
|
@ -523,7 +523,7 @@ fn initgroups_dyn(
|
||||||
size.* = @intCast(c_long, newsize);
|
size.* = @intCast(c_long, newsize);
|
||||||
} else |err| switch (err) {
|
} else |err| switch (err) {
|
||||||
error.OutOfMemory => {
|
error.OutOfMemory => {
|
||||||
errnop.* = @enumToInt(os.E.NOMEM);
|
errnop.* = @intFromEnum(os.E.NOMEM);
|
||||||
return c.NSS_STATUS_TRYAGAIN;
|
return c.NSS_STATUS_TRYAGAIN;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -540,14 +540,14 @@ fn initgroups_dyn(
|
||||||
fn getDBErrno(errnop: *c_int) ?*const DB {
|
fn getDBErrno(errnop: *c_int) ?*const DB {
|
||||||
global_init.call();
|
global_init.call();
|
||||||
var state = &(global_state orelse {
|
var state = &(global_state orelse {
|
||||||
errnop.* = @enumToInt(os.E.AGAIN);
|
errnop.* = @intFromEnum(os.E.AGAIN);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
return &state.file.db;
|
return &state.file.db;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn badFile(errnop: *c_int) c.enum_nss_status {
|
fn badFile(errnop: *c_int) c.enum_nss_status {
|
||||||
errnop.* = @enumToInt(os.E.NOENT);
|
errnop.* = @intFromEnum(os.E.NOENT);
|
||||||
return c.NSS_STATUS_NOTFOUND;
|
return c.NSS_STATUS_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,7 +605,7 @@ test "libnss getpwuid_r and getpwnam_r" {
|
||||||
c.NSS_STATUS_NOTFOUND,
|
c.NSS_STATUS_NOTFOUND,
|
||||||
getpwnam_r(&state.file.db, "does not exist", &passwd, &buf, buf.len, &errno),
|
getpwnam_r(&state.file.db, "does not exist", &passwd, &buf, buf.len, &errno),
|
||||||
);
|
);
|
||||||
try testing.expectEqual(@enumToInt(os.E.NOENT), @intCast(u16, errno));
|
try testing.expectEqual(@intFromEnum(os.E.NOENT), @intCast(u16, errno));
|
||||||
|
|
||||||
passwd = undefined;
|
passwd = undefined;
|
||||||
var small_buffer: [1]u8 = undefined;
|
var small_buffer: [1]u8 = undefined;
|
||||||
|
@ -613,7 +613,7 @@ test "libnss getpwuid_r and getpwnam_r" {
|
||||||
c.NSS_STATUS_TRYAGAIN,
|
c.NSS_STATUS_TRYAGAIN,
|
||||||
getpwuid_r(&state.file.db, 0, &passwd, &small_buffer, small_buffer.len, &errno),
|
getpwuid_r(&state.file.db, 0, &passwd, &small_buffer, small_buffer.len, &errno),
|
||||||
);
|
);
|
||||||
try testing.expectEqual(@enumToInt(os.E.RANGE), @intCast(u16, errno));
|
try testing.expectEqual(@intFromEnum(os.E.RANGE), @intCast(u16, errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn testVidmantas(u: CUser) !void {
|
fn testVidmantas(u: CUser) !void {
|
||||||
|
@ -657,7 +657,7 @@ test "libnss getgrgid_r and getgrnam_r" {
|
||||||
c.NSS_STATUS_NOTFOUND,
|
c.NSS_STATUS_NOTFOUND,
|
||||||
getgrnam_r(&state, "does not exist", &group, &buf, buf.len, &errno),
|
getgrnam_r(&state, "does not exist", &group, &buf, buf.len, &errno),
|
||||||
);
|
);
|
||||||
try testing.expectEqual(@enumToInt(os.E.NOENT), @intCast(u16, errno));
|
try testing.expectEqual(@intFromEnum(os.E.NOENT), @intCast(u16, errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn testSvcGroup(g: CGroup) !void {
|
fn testSvcGroup(g: CGroup) !void {
|
||||||
|
|
|
@ -132,7 +132,7 @@ pub const ShellWriter = struct {
|
||||||
try deque.add(KV{ .shell = entry.key_ptr.*, .score = score });
|
try deque.add(KV{ .shell = entry.key_ptr.*, .score = score });
|
||||||
}
|
}
|
||||||
|
|
||||||
const total = std.math.min(deque.count(), limit);
|
const total = @min(deque.count(), limit);
|
||||||
var topShells = BoundedArray([]const u8, max_shells).init(total) catch unreachable;
|
var topShells = BoundedArray([]const u8, max_shells).init(total) catch unreachable;
|
||||||
|
|
||||||
var i: u32 = 0;
|
var i: u32 = 0;
|
||||||
|
|
Loading…
Reference in New Issue