mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
compiler: add some missing consts
The previous commit exposed some missing `const` qualifiers in a few places. These mutable slices could have been used to store invalid values into memory!
This commit is contained in:
parent
f154cd1fdc
commit
3e9810266b
4 changed files with 8 additions and 8 deletions
|
|
@ -1364,20 +1364,20 @@ fn usage(b: *std.Build, out_stream: anytype) !void {
|
|||
);
|
||||
}
|
||||
|
||||
fn nextArg(args: [][:0]const u8, idx: *usize) ?[:0]const u8 {
|
||||
fn nextArg(args: []const [:0]const u8, idx: *usize) ?[:0]const u8 {
|
||||
if (idx.* >= args.len) return null;
|
||||
defer idx.* += 1;
|
||||
return args[idx.*];
|
||||
}
|
||||
|
||||
fn nextArgOrFatal(args: [][:0]const u8, idx: *usize) [:0]const u8 {
|
||||
fn nextArgOrFatal(args: []const [:0]const u8, idx: *usize) [:0]const u8 {
|
||||
return nextArg(args, idx) orelse {
|
||||
std.debug.print("expected argument after '{s}'\n access the help menu with 'zig build -h'\n", .{args[idx.* - 1]});
|
||||
process.exit(1);
|
||||
};
|
||||
}
|
||||
|
||||
fn argsRest(args: [][:0]const u8, idx: usize) ?[][:0]const u8 {
|
||||
fn argsRest(args: []const [:0]const u8, idx: usize) ?[]const [:0]const u8 {
|
||||
if (idx >= args.len) return null;
|
||||
return args[idx..];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2224,8 +2224,8 @@ pub const ErrorMsg = extern struct {
|
|||
|
||||
pub const LoadFromCommandLine = ZigClangLoadFromCommandLine;
|
||||
extern fn ZigClangLoadFromCommandLine(
|
||||
args_begin: [*]?[*]const u8,
|
||||
args_end: [*]?[*]const u8,
|
||||
args_begin: [*]?[*:0]const u8,
|
||||
args_end: [*]?[*:0]const u8,
|
||||
errors_ptr: *[*]ErrorMsg,
|
||||
errors_len: *usize,
|
||||
resources_path: [*:0]const u8,
|
||||
|
|
|
|||
|
|
@ -997,7 +997,7 @@ fn markRelocsDirtyByAddress(coff: *Coff, addr: u32) void {
|
|||
}
|
||||
}
|
||||
|
||||
fn resolveRelocs(coff: *Coff, atom_index: Atom.Index, relocs: []*const Relocation, code: []u8, image_base: u64) void {
|
||||
fn resolveRelocs(coff: *Coff, atom_index: Atom.Index, relocs: []const *const Relocation, code: []u8, image_base: u64) void {
|
||||
log.debug("relocating '{s}'", .{coff.getAtom(atom_index).getName(coff)});
|
||||
for (relocs) |reloc| {
|
||||
reloc.resolve(atom_index, code, image_base, coff);
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ pub const Context = struct {
|
|||
|
||||
pub fn translate(
|
||||
gpa: mem.Allocator,
|
||||
args_begin: [*]?[*]const u8,
|
||||
args_end: [*]?[*]const u8,
|
||||
args_begin: [*]?[*:0]const u8,
|
||||
args_end: [*]?[*:0]const u8,
|
||||
errors: *std.zig.ErrorBundle,
|
||||
resources_path: [*:0]const u8,
|
||||
) !std.zig.Ast {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue