From f0fdaf32d3b802e9db16a0753d9ff49a8667089b Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Wed, 10 May 2023 16:26:54 +0300 Subject: [PATCH] fix incorrect use of mutable pointers to temporary values --- lib/std/os/linux/x86.zig | 2 +- src/Module.zig | 2 +- src/link/MachO/Atom.zig | 2 +- test/behavior/array.zig | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/std/os/linux/x86.zig b/lib/std/os/linux/x86.zig index 2e67fa6b5b..c9274e11ee 100644 --- a/lib/std/os/linux/x86.zig +++ b/lib/std/os/linux/x86.zig @@ -108,7 +108,7 @@ pub fn syscall6( ); } -pub fn socketcall(call: usize, args: [*]usize) usize { +pub fn socketcall(call: usize, args: [*]const usize) usize { return asm volatile ("int $0x80" : [ret] "={eax}" (-> usize), : [number] "{eax}" (@enumToInt(SYS.socketcall)), diff --git a/src/Module.zig b/src/Module.zig index b0c18def78..6d1a5acb09 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -6098,7 +6098,7 @@ pub const PeerTypeCandidateSrc = union(enum) { none: void, /// When we want to know the the src of candidate i, look up at /// index i in this slice - override: []?LazySrcLoc, + override: []const ?LazySrcLoc, /// resolvePeerTypes originates from a @TypeOf(...) call typeof_builtin_call_node_offset: i32, diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig index fb05595b7d..970371e455 100644 --- a/src/link/MachO/Atom.zig +++ b/src/link/MachO/Atom.zig @@ -116,7 +116,7 @@ pub fn addRelocation(macho_file: *MachO, atom_index: Index, reloc: Relocation) ! return addRelocations(macho_file, atom_index, &[_]Relocation{reloc}); } -pub fn addRelocations(macho_file: *MachO, atom_index: Index, relocs: []Relocation) !void { +pub fn addRelocations(macho_file: *MachO, atom_index: Index, relocs: []const Relocation) !void { const gpa = macho_file.base.allocator; const gop = try macho_file.relocs.getOrPut(gpa, atom_index); if (!gop.found_existing) { diff --git a/test/behavior/array.zig b/test/behavior/array.zig index 6cf0ab9e1d..a54aaa898e 100644 --- a/test/behavior/array.zig +++ b/test/behavior/array.zig @@ -667,7 +667,7 @@ test "array init of container level array variable" { test "runtime initialized sentinel-terminated array literal" { var c: u16 = 300; const f = &[_:0x9999]u16{c}; - const g = @ptrCast(*[4]u8, f); + const g = @ptrCast(*const [4]u8, f); try std.testing.expect(g[2] == 0x99); try std.testing.expect(g[3] == 0x99); }