1
Fork 0

styling some for loops

This commit is contained in:
Motiejus Jakštys 2023-04-13 11:26:26 +03:00
parent c9bb95f395
commit d7ca840de8
2 changed files with 3 additions and 5 deletions

View File

@ -580,8 +580,7 @@ fn usersSection(
// 8 bytes. 24 is an optimistic lower bound for an average record size. // 8 bytes. 24 is an optimistic lower bound for an average record size.
var blob = try ArrayListAligned(u8, 8).initCapacity(allocator, 24 * corpus.users.len); var blob = try ArrayListAligned(u8, 8).initCapacity(allocator, 24 * corpus.users.len);
errdefer blob.deinit(); errdefer blob.deinit();
var i: usize = 0; for (0..corpus.users.len) |i| {
while (i < corpus.users.len) : (i += 1) {
// TODO: this may be inefficient by calling `.slice()` on every iteration? // TODO: this may be inefficient by calling `.slice()` on every iteration?
const user = corpus.users.get(i); const user = corpus.users.get(i);
const user_offset = math.cast(u35, blob.items.len) orelse return error.TooMany; const user_offset = math.cast(u35, blob.items.len) orelse return error.TooMany;
@ -873,8 +872,7 @@ test "DB additionalGids" {
defer allocator.free(additional_gids.idx2offset); defer allocator.free(additional_gids.idx2offset);
defer allocator.free(additional_gids.blob); defer allocator.free(additional_gids.blob);
var user_idx: usize = 0; for (0..corpus.users.len) |user_idx| {
while (user_idx < corpus.users.len) : (user_idx += 1) {
const groups = corpus.user2groups[user_idx]; const groups = corpus.user2groups[user_idx];
const offset = additional_gids.idx2offset[user_idx]; const offset = additional_gids.idx2offset[user_idx];
if (groups.len == 0) { if (groups.len == 0) {

View File

@ -131,7 +131,7 @@ fn dump_passwd(wr: anytype, num_users: u64) error{IO}!void {
const gecos = fmt.bufPrint(buf_gecos[0..], "User {d}", .{i}) catch unreachable; const gecos = fmt.bufPrint(buf_gecos[0..], "User {d}", .{i}) catch unreachable;
const home = fmt.bufPrint(buf_home[0..], "/home/{s}", .{name}) catch unreachable; const home = fmt.bufPrint(buf_home[0..], "/home/{s}", .{name}) catch unreachable;
const user = User{ const user = User{
.uid = i, .uid = @intCast(u32, i),
.gid = 1000000, .gid = 1000000,
.name = name, .name = name,
.gecos = gecos, .gecos = gecos,