diff --git a/src/shell.zig b/src/shell.zig index 47d4e04..a1174fd 100644 --- a/src/shell.zig +++ b/src/shell.zig @@ -61,7 +61,7 @@ pub const ShellWriter = struct { }; var fullOffset: u12 = 0; var idx: u6 = 0; - while (idx < shells.len) { + while (idx < shells.len) : (idx += 1) { const len = @intCast(u6, shells.get(idx).len); try self.blob.appendSlice(shells.get(idx)); const ourShell = self.blob.constSlice()[fullOffset .. fullOffset + len]; @@ -77,7 +77,6 @@ pub const ShellWriter = struct { //const stderr = std.io.getStdErr().writer(); //stderr.print("\n", .{}) catch unreachable; try self.blob.appendNTimes(0, padding); - idx += 1; } return self; } @@ -155,10 +154,9 @@ pub const ShellWriter = struct { var topShells = try BoundedArray([]const u8, MaxShells).init(total); var i: u32 = 0; - while (i < total) { + while (i < total) : (i += 1) { const elem = deque.removeMax().shell; topShells.set(i, elem); - i += 1; } const result = ShellSections.init(self.allocator, topShells); diff --git a/src/user.zig b/src/user.zig index e4b9313..8aab1a4 100644 --- a/src/user.zig +++ b/src/user.zig @@ -17,7 +17,7 @@ pub const PackedUser = packed struct { name_len: u5, gecos_len: u8, }; -const PackedUserAlignment = 3; // bits +const PackedUserAlignmentBits = 3; pub const User = struct { uid: u32, @@ -35,6 +35,7 @@ pub const UserWriter = struct { // function makes tests easier, and removes the Shell dependency of this // module. const shellIndexFnType = fn ([]const u8) ?u6; + appendTo: *ArrayList(u8), shellIndexFn: shellIndexFnType, @@ -45,9 +46,7 @@ pub const UserWriter = struct { }; } - const fromUserErr = error{InvalidRecord}; - - pub fn downCast(comptime T: type, n: u64) fromUserErr!T { + pub fn downCast(comptime T: type, n: u64) error{InvalidRecord}!T { return std.math.cast(T, n) catch |err| switch (err) { error.Overflow => { return error.InvalidRecord; @@ -85,7 +84,7 @@ pub const UserWriter = struct { try self.appendTo.appendNTimes(0, pad.roundUpPadding( u64, - PackedUserAlignment, + PackedUserAlignmentBits, self.appendTo.items.len, )); }