mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-08-05 21:37:15 +02:00
56 lines
2.1 KiB
Diff
56 lines
2.1 KiB
Diff
From 5e40820838eaaf78e95132cb6fdc906686904480 Mon Sep 17 00:00:00 2001
|
|
From: "lauren n. liberda" <lauren@selfisekai.rocks>
|
|
Date: Sat, 20 Apr 2024 22:29:48 +0200
|
|
Subject: [PATCH] zig 0.12: convert some vars to consts
|
|
|
|
solves "error: local variable is never mutated"
|
|
---
|
|
src/args.zig | 6 +++---
|
|
src/main.zig | 2 +-
|
|
2 files changed, 4 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/args.zig b/src/args.zig
|
|
index a243c98..89a980e 100644
|
|
--- a/src/args.zig
|
|
+++ b/src/args.zig
|
|
@@ -401,7 +401,7 @@ fn parseInt(comptime T: type, str: []const u8) !T {
|
|
base1024 = true;
|
|
}
|
|
if (buf.len != 0) {
|
|
- var pow: u3 = switch (buf[buf.len - 1]) {
|
|
+ const pow: u3 = switch (buf[buf.len - 1]) {
|
|
'k', 'K' => 1, //kilo
|
|
'm', 'M' => 2, //mega
|
|
'g', 'G' => 3, //giga
|
|
@@ -415,7 +415,7 @@ fn parseInt(comptime T: type, str: []const u8) !T {
|
|
|
|
if (comptime std.math.maxInt(T) < 1024)
|
|
return error.Overflow;
|
|
- var base: T = if (base1024) 1024 else 1000;
|
|
+ const base: T = if (base1024) 1024 else 1000;
|
|
multiplier = try std.math.powi(T, base, @intCast(pow));
|
|
}
|
|
}
|
|
@@ -567,7 +567,7 @@ pub const ErrorCollection = struct {
|
|
|
|
/// Appends an error to the collection
|
|
fn insert(self: *Self, err: Error) !void {
|
|
- var dupe = Error{
|
|
+ const dupe = Error{
|
|
.option = try self.arena.allocator().dupe(u8, err.option),
|
|
.kind = switch (err.kind) {
|
|
.invalid_value => |v| Error.Kind{
|
|
diff --git a/src/main.zig b/src/main.zig
|
|
index 7759ebc..38f2a99 100644
|
|
--- a/src/main.zig
|
|
+++ b/src/main.zig
|
|
@@ -440,7 +440,7 @@ pub fn main() anyerror!void {
|
|
help();
|
|
return;
|
|
}
|
|
- var key: []const u8 = options.positionals[1];
|
|
+ const key: []const u8 = options.positionals[1];
|
|
var value: []const u8 = undefined;
|
|
if (options.positionals.len >= 3) {
|
|
value = options.positionals[2];
|