1
Fork 0

fix one TODO

This commit is contained in:
Motiejus Jakštys 2023-06-06 19:12:46 +03:00
parent 4962c7286b
commit 325c01b341
3 changed files with 3 additions and 9 deletions

View File

@ -327,7 +327,6 @@ pub fn groupMembersIter(members_slice: []const u8) GroupMembersIter {
pub fn packCGroup(self: *const DB, group: *const PackedGroup, buf: []u8) error{BufferTooSmall}!CGroup {
const members_slice = self.groupmembers[group.members_offset..];
var it = groupMembersIter(members_slice);
const num_members = it.total;
const ptr_end = @sizeOf(?[*:0]const u8) * (num_members + 1);

View File

@ -484,11 +484,8 @@ fn initgroups_dyn(
return c.NSS_STATUS_NOTFOUND;
};
// TODO: use db.userGids()
const offset = user.additional_gids_offset;
var vit = compress.varintSliceIteratorMust(db.additional_gids[offset..]);
var gids = compress.deltaDecompressionIterator(&vit);
const remaining = vit.remaining;
var gids = db.userGids(user.additional_gids_offset);
const remaining = gids.vit.remaining;
// the implementation below is ported from glibc's db-initgroups.c
// even though we know the size of the groups upfront, I found it too difficult

View File

@ -224,10 +224,8 @@ fn splitInt(n: u64) BoundedArray(u8, max_len) {
var result = BoundedArray(u8, max_len).init(0) catch unreachable;
var buf: [max_len]u8 = undefined;
const str = fmt.bufPrint(buf[0..], "{d}", .{n}) catch unreachable;
var remaining: usize = str.len;
for (str) |c| {
for (str, str.len..0) |c, remaining| {
result.append(c) catch unreachable;
remaining -= 1;
if (remaining > 0 and remaining % 3 == 0)
result.append(',') catch unreachable;
}