math: make cast return optional instead of an error
This commit is contained in:
committed by
Andrew Kelley
parent
ddd5b57045
commit
0e6285c8fc
@@ -4395,7 +4395,7 @@ pub fn embedFile(mod: *Module, cur_file: *File, rel_file_path: []const u8) !*Emb
|
||||
.inode = actual_stat.inode,
|
||||
.mtime = actual_stat.mtime,
|
||||
};
|
||||
const size_usize = try std.math.cast(usize, actual_stat.size);
|
||||
const size_usize = std.math.cast(usize, actual_stat.size) orelse return error.Overflow;
|
||||
const bytes = try file.readToEndAllocOptions(gpa, std.math.maxInt(u32), size_usize, 1, 0);
|
||||
errdefer gpa.free(bytes);
|
||||
|
||||
@@ -4435,7 +4435,7 @@ pub fn detectEmbedFileUpdate(mod: *Module, embed_file: *EmbedFile) !void {
|
||||
if (unchanged_metadata) return;
|
||||
|
||||
const gpa = mod.gpa;
|
||||
const size_usize = try std.math.cast(usize, stat.size);
|
||||
const size_usize = std.math.cast(usize, stat.size) orelse return error.Overflow;
|
||||
const bytes = try file.readToEndAllocOptions(gpa, std.math.maxInt(u32), size_usize, 1, 0);
|
||||
gpa.free(embed_file.bytes);
|
||||
embed_file.bytes = bytes;
|
||||
|
||||
Reference in New Issue
Block a user