some explicit errors in function signatures
This commit is contained in:
parent
d3be68b51d
commit
1caf3f1184
@ -42,16 +42,11 @@ const Corpus = struct {
|
|||||||
groupname2users: StringHashMap([]*const User),
|
groupname2users: StringHashMap([]*const User),
|
||||||
username2groups: StringHashMap([]*const Group),
|
username2groups: StringHashMap([]*const Group),
|
||||||
|
|
||||||
pub const initErr = Allocator.Error ||
|
|
||||||
error{InvalidUtf8} ||
|
|
||||||
error{Duplicate} ||
|
|
||||||
error{NotFound};
|
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
baseAllocator: Allocator,
|
baseAllocator: Allocator,
|
||||||
usersConst: []const User,
|
usersConst: []const User,
|
||||||
groupsConst: []const Group,
|
groupsConst: []const Group,
|
||||||
) initErr!Corpus {
|
) error{ OutOfMemory, InvalidUtf8, Duplicate, NotFound }!Corpus {
|
||||||
var arena = std.heap.ArenaAllocator.init(baseAllocator);
|
var arena = std.heap.ArenaAllocator.init(baseAllocator);
|
||||||
var allocator = arena.allocator();
|
var allocator = arena.allocator();
|
||||||
errdefer arena.deinit();
|
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
|
// - shell module should accept a list of shells and spit out two slices
|
||||||
// (allocated with a given allocator). There is too much dancing around
|
// (allocated with a given allocator). There is too much dancing around
|
||||||
// here.
|
// here.
|
||||||
const shellSectionsErr = Allocator.Error || error{Overflow};
|
|
||||||
pub fn shellSections(
|
pub fn shellSections(
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
corpus: *const Corpus,
|
corpus: *const Corpus,
|
||||||
) shellSectionsErr!ShellSections {
|
) error{ OutOfMemory, Overflow }!ShellSections {
|
||||||
var popcon = shellImport.ShellWriter.init(allocator);
|
var popcon = shellImport.ShellWriter.init(allocator);
|
||||||
for (corpus.usersMulti.items(.shell)) |shell| {
|
for (corpus.usersMulti.items(.shell)) |shell| {
|
||||||
try popcon.put(shell);
|
try popcon.put(shell);
|
||||||
@ -227,8 +221,10 @@ pub const UserGids = struct {
|
|||||||
|
|
||||||
const userGidsPaddingBits = 3;
|
const userGidsPaddingBits = 3;
|
||||||
|
|
||||||
const userGidsErr = Allocator.Error || error{Overflow};
|
pub fn userGids(
|
||||||
pub fn userGids(allocator: Allocator, corpus: *const Corpus) userGidsErr!UserGids {
|
allocator: Allocator,
|
||||||
|
corpus: *const Corpus,
|
||||||
|
) error{ OutOfMemory, Overflow }!UserGids {
|
||||||
var blob = ArrayList(u8).init(allocator);
|
var blob = ArrayList(u8).init(allocator);
|
||||||
errdefer blob.deinit();
|
errdefer blob.deinit();
|
||||||
var name2offset = StringHashMap(u32).init(allocator);
|
var name2offset = StringHashMap(u32).init(allocator);
|
||||||
@ -287,7 +283,10 @@ pub fn usersSection(
|
|||||||
return buf.toOwnedSlice();
|
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 buf: [compress.maxVarintLen64]u8 = undefined;
|
||||||
var offsets = ArrayListUnmanaged(usize).initCapacity(
|
var offsets = ArrayListUnmanaged(usize).initCapacity(
|
||||||
allocator,
|
allocator,
|
||||||
|
Loading…
Reference in New Issue
Block a user