From a50016c7481b4c8613e03af136d93309c6b30400 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Mon, 4 Dec 2023 20:19:18 +0100 Subject: Update code for Zig dev This code was tested on zig-dev-bin-1:0.12.0_dev.1773+8a8fd47d2-1 (AUR) --- .github/workflows/main.yml | 2 +- build.zig.zon | 2 +- src/main.zig | 10 +++++----- tool/znk.zig | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 47b2ee8..544d23a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install the latest Zig version - run: sudo snap install zig --classic --beta + run: sudo snap install zig --classic --edge - uses: actions/checkout@v2 diff --git a/build.zig.zon b/build.zig.zon index d922fdd..b3c562d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,5 +1,5 @@ .{ .name = "zig-nkeys", - .version = "0.5.1", + .version = "0.6.0", .paths = .{"."}, } diff --git a/src/main.zig b/src/main.zig index a93c0ea..b24faea 100644 --- a/src/main.zig +++ b/src/main.zig @@ -286,11 +286,11 @@ fn encode( var buf: [prefix_len + data_len + 2]u8 = undefined; defer wipeBytes(&buf); - mem.copy(u8, &buf, prefix[0..]); - mem.copy(u8, buf[prefix_len..], data[0..]); + mem.copyForwards(u8, &buf, prefix[0..]); + mem.copyForwards(u8, buf[prefix_len..], data[0..]); const off = prefix_len + data_len; const checksum = crc16.make(buf[0..off]); - mem.writeIntLittle(u16, buf[buf.len - 2 .. buf.len], checksum); + mem.writeInt(u16, buf[buf.len - 2 .. buf.len], checksum, .little); var text: encoded_key(prefix_len, data_len) = undefined; std.debug.assert(base32.Encoder.encode(&text, &buf).len == text.len); @@ -321,7 +321,7 @@ fn decode( defer wipeBytes(&raw); std.debug.assert((try base32.Decoder.decode(&raw, text[0..])).len == raw.len); - const checksum = mem.readIntLittle(u16, raw[raw.len - 2 .. raw.len]); + const checksum = mem.readInt(u16, raw[raw.len - 2 .. raw.len], .little); try crc16.validate(raw[0 .. raw.len - 2], checksum); return DecodedNkey(prefix_len, data_len){ @@ -347,7 +347,7 @@ pub fn isValidEncoding(text: []const u8) bool { } std.debug.assert(wrote_n_total == expect_len); if (crc_buf_len != 2) unreachable; - const got_crc = mem.readIntLittle(u16, &crc_buf); + const got_crc = mem.readInt(u16, &crc_buf, .little); return made_crc == got_crc; } diff --git a/tool/znk.zig b/tool/znk.zig index fb2412f..af8f757 100644 --- a/tool/znk.zig +++ b/tool/znk.zig @@ -420,7 +420,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type { role: nkeys.Role, prefix: []const u8, allocator: Allocator, - done: std.atomic.Atomic(bool), + done: std.atomic.Value(bool), entropy: ?EntropyReaderType, const Self = @This(); @@ -430,7 +430,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type { .role = role, .prefix = prefix, .allocator = allocator, - .done = std.atomic.Atomic(bool).init(false), + .done = std.atomic.Value(bool).init(false), .entropy = entropy, }; } -- cgit v1.2.3