Tidy up some mem.spanZ use-sites now that null is accepted

This commit is contained in:
daurnimator 2020-04-01 01:25:25 +11:00
parent b1eb831aba
commit 3cf302a71d
No known key found for this signature in database
GPG Key ID: 45B429A8F9D9D22A
3 changed files with 5 additions and 6 deletions

View File

@ -1254,7 +1254,7 @@ pub const DebugInfo = struct {
if (context.address >= seg_start and context.address < seg_end) {
// Android libc uses NULL instead of an empty string to mark the
// main program
context.name = if (info.dlpi_name) |dlpi_name| mem.spanZ(dlpi_name) else "";
context.name = mem.spanZ(info.dlpi_name) orelse "";
context.base_address = info.dlpi_addr;
// Stop the iteration
return error.Found;

View File

@ -1078,7 +1078,7 @@ pub fn execvpe_expandArg0(
mem.set(?[*:0]u8, argv_buf, null);
defer {
for (argv_buf) |arg| {
const arg_buf = if (arg) |ptr| mem.spanZ(ptr) else break;
const arg_buf = mem.spanZ(arg) orelse break;
allocator.free(arg_buf);
}
allocator.free(argv_buf);

View File

@ -689,12 +689,11 @@ fn stage2CrossTarget(
mcpu_oz: ?[*:0]const u8,
dynamic_linker_oz: ?[*:0]const u8,
) !CrossTarget {
const zig_triple = if (zig_triple_oz) |zig_triple_z| mem.spanZ(zig_triple_z) else "native";
const mcpu = if (mcpu_oz) |mcpu_z| mem.spanZ(mcpu_z) else null;
const dynamic_linker = if (dynamic_linker_oz) |dl_z| mem.spanZ(dl_z) else null;
const mcpu = mem.spanZ(mcpu_oz);
const dynamic_linker = mem.spanZ(dynamic_linker_oz);
var diags: CrossTarget.ParseOptions.Diagnostics = .{};
const target: CrossTarget = CrossTarget.parse(.{
.arch_os_abi = zig_triple,
.arch_os_abi = mem.spanZ(zig_triple_oz) orelse "native",
.cpu_features = mcpu,
.dynamic_linker = dynamic_linker,
.diagnostics = &diags,