some explicit errors in function signatures

This commit is contained in:
Motiejus Jakštys 2022-03-06 18:01:52 +02:00 committed by Motiejus Jakštys
parent d3be68b51d
commit 1caf3f1184

View File

@ -42,16 +42,11 @@ const Corpus = struct {
groupname2users: StringHashMap([]*const User),
username2groups: StringHashMap([]*const Group),
pub const initErr = Allocator.Error ||
error{InvalidUtf8} ||
error{Duplicate} ||
error{NotFound};
pub fn init(
baseAllocator: Allocator,
usersConst: []const User,
groupsConst: []const Group,
) initErr!Corpus {
) error{ OutOfMemory, InvalidUtf8, Duplicate, NotFound }!Corpus {
var arena = std.heap.ArenaAllocator.init(baseAllocator);
var allocator = arena.allocator();
errdefer arena.deinit();
@ -196,11 +191,10 @@ pub fn bdzUsername(allocator: Allocator, corpus: *const Corpus) cmph.Error![]con
// - shell module should accept a list of shells and spit out two slices
// (allocated with a given allocator). There is too much dancing around
// here.
const shellSectionsErr = Allocator.Error || error{Overflow};
pub fn shellSections(
allocator: Allocator,
corpus: *const Corpus,
) shellSectionsErr!ShellSections {
) error{ OutOfMemory, Overflow }!ShellSections {
var popcon = shellImport.ShellWriter.init(allocator);
for (corpus.usersMulti.items(.shell)) |shell| {
try popcon.put(shell);
@ -227,8 +221,10 @@ pub const UserGids = struct {
const userGidsPaddingBits = 3;
const userGidsErr = Allocator.Error || error{Overflow};
pub fn userGids(allocator: Allocator, corpus: *const Corpus) userGidsErr!UserGids {
pub fn userGids(
allocator: Allocator,
corpus: *const Corpus,
) error{ OutOfMemory, Overflow }!UserGids {
var blob = ArrayList(u8).init(allocator);
errdefer blob.deinit();
var name2offset = StringHashMap(u32).init(allocator);
@ -287,7 +283,10 @@ pub fn usersSection(
return buf.toOwnedSlice();
}
pub fn groupMembers(allocator: Allocator, corpus: *const Corpus) Allocator.Error!void {
pub fn groupMembers(
allocator: Allocator,
corpus: *const Corpus,
) error{OutOfMemory}!void {
var buf: [compress.maxVarintLen64]u8 = undefined;
var offsets = ArrayListUnmanaged(usize).initCapacity(
allocator,