CGroup.name is [*]u8 now
This commit is contained in:
parent
3eeb0a8332
commit
ce827a9ae6
@ -261,7 +261,7 @@ fn getGroup(
|
||||
buf.*[buf_offset + name.len] = 0;
|
||||
|
||||
return CGroup{
|
||||
.name = buf.*[buf_offset .. buf_offset + name.len :0],
|
||||
.name = buf.*[buf_offset .. buf_offset + name.len].ptr,
|
||||
.gid = group.gid(),
|
||||
.members = member_ptrs,
|
||||
};
|
||||
@ -605,7 +605,7 @@ test "high-level API" {
|
||||
const all = try db.getgrnam("all", &buf);
|
||||
try testing.expect(all != null);
|
||||
try testing.expectEqual(all.?.gid, 9999);
|
||||
try testing.expectEqualStrings(mem.sliceTo(all.?.name, 0), "all");
|
||||
try testing.expectEqualStrings(all.?.name[0..3], "all");
|
||||
const members = all.?.members;
|
||||
try testing.expectEqualStrings(mem.sliceTo(members[0].?, 0), "Name" ** 8);
|
||||
try testing.expectEqualStrings(mem.sliceTo(members[1].?, 0), "root");
|
||||
@ -623,7 +623,7 @@ test "high-level API" {
|
||||
const all_gid = try db.getgrgid(9999, &buf);
|
||||
try testing.expect(all_gid != null);
|
||||
try testing.expectEqual(all_gid.?.gid, 9999);
|
||||
try testing.expectEqualStrings(mem.sliceTo(all_gid.?.name, 0), "all");
|
||||
try testing.expectEqualStrings(all_gid.?.name[0..3], "all");
|
||||
}
|
||||
|
||||
test "getgr_bufsize" {
|
||||
|
@ -8,14 +8,14 @@ const meta = @import("std").meta;
|
||||
pub const CGroup = struct {
|
||||
gid: u32,
|
||||
// should be [*:0]const u8
|
||||
name: []const u8,
|
||||
name: [*]const u8,
|
||||
// Should be [*:null]align(1) const ?[*:0]const u8
|
||||
members: []align(1) const ?[*:0]const u8,
|
||||
|
||||
pub fn ptr(self: *const CGroup) CGroupPtr {
|
||||
return CGroupPtr{
|
||||
.gid = self.gid,
|
||||
.name = self.name.ptr,
|
||||
.name = self.name,
|
||||
.members = @intToPtr([*]const u8, @ptrToInt(self.members.ptr)),
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user