diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-21 14:38:16 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-21 14:44:48 -0300 |
| commit | d5c37d9122240fe95d308fbe15874e14dd786c5a (patch) | |
| tree | 3ed108d2af5bd7a5cb07491b16e855e5243b5d63 /src | |
| parent | fe9772b178575fcab93de09fc61c2f13db7db1a8 (diff) | |
| download | cloud9-d5c37d9122240fe95d308fbe15874e14dd786c5a.tar.gz cloud9-d5c37d9122240fe95d308fbe15874e14dd786c5a.zip | |
Build with Zig 0.17
Diffstat (limited to 'src')
| -rw-r--r-- | src/fs.zig | 4 | ||||
| -rw-r--r-- | src/post.zig | 48 | ||||
| -rw-r--r-- | src/quic.zig | 2 | ||||
| -rw-r--r-- | src/serve.zig | 10 | ||||
| -rw-r--r-- | src/transport.zig | 2 | ||||
| -rw-r--r-- | src/wire.zig | 44 |
6 files changed, 55 insertions, 55 deletions
@@ -2068,7 +2068,7 @@ test "fs server: backend-sized filenames survive walk and stat within negotiated var encoded: [1024]u8 = undefined; var server = Native.init(.{ .in = &in, .out = &out, .root = 1 }); server.protocol.msize = case.msize; - server.setUname("u" ** Native.options.username_capacity); + server.setUname(&@as([Native.options.username_capacity]u8, @splat('u'))); server.fids[0] = .{ .used = true, .fid = 0, .node = 1, .dir = true, .perm = 0o500 }; const name = filename[0..case.length]; const walk = try encode(.{ .twalk = .{ @@ -2738,7 +2738,7 @@ test "fs server: a message arriving a byte at a time is served when its last byt } test "fs server: invalid framing and reply types terminate the connection" { - for ([_]u8{ @intFromEnum(wire.Type.rstat), 8, 0 }) |kind| { + for ([_]u8{ @backingInt(wire.Type.rstat), 8, 0 }) |kind| { var h: Harness = .{}; try h.handshake(4096); var buf: [64]u8 = undefined; diff --git a/src/post.zig b/src/post.zig index 641970d..1355b56 100644 --- a/src/post.zig +++ b/src/post.zig @@ -191,7 +191,7 @@ fn socketNonblocking() !i32 { /// directly. fn rawErrno(rc: isize) linux.E { const n: usize = if (rc < 0 and -rc < 4096) @intCast(-rc) else 0; - return @enumFromInt(n); + return @fromBackingInt(@intCast(n)); } pub const DialError = error{ @@ -329,7 +329,7 @@ pub fn post(io: Io, env: Env, name: []const u8, backlog: u31, path_buf: []u8) Po const parent = dir_path[0 .. dir_path.len - "/9p".len]; const serial = temp_serial.fetchAdd(1, .monotonic); var tmp_buf: [std.fs.max_path_bytes]u8 = undefined; - const tmp = std.fmt.bufPrintZ(&tmp_buf, "{s}/.post.sock.{d}.{d}", .{ parent, linux.getpid(), serial }) catch return error.NoSpace; + const tmp = std.fmt.bufPrintSentinel(&tmp_buf, "{s}/.post.sock.{d}.{d}", .{ parent, linux.getpid(), serial }, 0) catch return error.NoSpace; var attempts: usize = 0; var saw_not_socket = false; claim: while (attempts < post_attempts) : (attempts += 1) { @@ -456,7 +456,7 @@ fn claimName(io: Io, registry_dir: [:0]const u8, path: [:0]const u8, sock_tmp: [ // registry directory, so no listing ever sees it. const dummy_serial = temp_serial.fetchAdd(1, .monotonic); var dummy_buf: [std.fs.max_path_bytes]u8 = undefined; - const dummy = std.fmt.bufPrintZ(&dummy_buf, "{s}/.post.tmp.{d}.{d}", .{ parent, linux.getpid(), dummy_serial }) catch return .retry; + const dummy = std.fmt.bufPrintSentinel(&dummy_buf, "{s}/.post.tmp.{d}.{d}", .{ parent, linux.getpid(), dummy_serial }, 0) catch return .retry; var dummy_file = Io.Dir.createFileAbsolute(io, dummy, .{ .exclusive = true, .truncate = false }) catch return .retry; dummy_file.close(io); const dummy_st = Io.Dir.statFile(.cwd(), io, dummy, .{}) catch { @@ -567,7 +567,7 @@ fn swapBack(path: [:0]const u8, tmp: [:0]const u8) isize { /// serialization. fn lockStaleRemoval(registry_dir: [:0]const u8) i32 { var buf: [std.fs.max_path_bytes]u8 = undefined; - const lock_path = std.fmt.bufPrintZ(&buf, "{s}/.post.lock", .{registry_dir[0 .. registry_dir.len - "/9p".len]}) catch return -1; + const lock_path = std.fmt.bufPrintSentinel(&buf, "{s}/.post.lock", .{registry_dir[0 .. registry_dir.len - "/9p".len]}, 0) catch return -1; const fd: isize = @bitCast(linux.open(lock_path.ptr, .{ .ACCMODE = .RDWR, .CREAT = true, .CLOEXEC = true }, 0o600)); if (rawErrno(fd) != .SUCCESS) return -1; const lfd: i32 = @intCast(fd); @@ -709,7 +709,7 @@ const Scratch = struct { s.dir = testing.tmpDir(.{}); errdefer s.dir.cleanup(); const len = try s.dir.dir.realPath(io, &s.path_buf); - const value = try std.fmt.bufPrintZ(&s.env_buf, "XDG_RUNTIME_DIR={s}", .{s.path_buf[0..len]}); + const value = try std.fmt.bufPrintSentinel(&s.env_buf, "XDG_RUNTIME_DIR={s}", .{s.path_buf[0..len]}, 0); s.env[0] = @ptrCast(value.ptr); s.env[1] = null; } @@ -735,7 +735,7 @@ test "post getenv: the block is scanned, keys match whole" { test "post legalName: traversal, empties and the socket budget" { try testing.expect(legalName("demo")); try testing.expect(legalName("...")); - try testing.expect(legalName("a" ** max_name_len)); + try testing.expect(legalName(&@as([max_name_len]u8, @splat('a')))); // Empty and dot names are not postable. try testing.expect(!legalName("")); try testing.expect(!legalName(".")); @@ -746,8 +746,8 @@ test "post legalName: traversal, empties and the socket budget" { try testing.expect(!legalName("..\x00..")); try testing.expect(!legalName("a\x00b")); // The name must fit a Unix socket path. - try testing.expect(!legalName("a" ** (max_name_len + 1))); - try testing.expect(!legalName("a" ** 255)); + try testing.expect(!legalName(&@as([max_name_len + 1]u8, @splat('a')))); + try testing.expect(!legalName(&@as([255]u8, @splat('a')))); } test "post registryPath: unset XDG is refused, no /tmp fallback" { @@ -773,7 +773,7 @@ test "post registryPath: shape, budget and caller buffer" { try testing.expectError(error.IllegalName, registryPath(e, "..", &buf)); // The 108-byte sockaddr budget, checked against the real prefix. const long_env = [_:null]?[*:0]const u8{"XDG_RUNTIME_DIR=/tmp/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}; - const name = "n" ** max_name_len; // legal against the 32-byte XDG budget + const name: []const u8 = &@as([max_name_len]u8, @splat('n')); // legal against the 32-byte XDG budget try testing.expectError(error.NameTooLong, registryPath(@ptrCast(&long_env), name, &buf)); // Too small a caller buffer is NoSpace, not a truncation. var tiny: [4]u8 = undefined; @@ -947,9 +947,9 @@ test "post names: a 255-byte entry stages and iterates (NAME_MAX)" { // A 255-byte name can never be a socket (108-byte budget), but an // attacker can drop one in the registry; the raw listing must carry // it without overflowing the staged `len:u8` record. - const fat = "z" ** 255; + const fat: []const u8 = &@as([255]u8, @splat('z')); var fat_buf: [std.fs.max_path_bytes]u8 = undefined; - const fat_path = try std.fmt.bufPrintZ(&fat_buf, "{s}/{s}", .{ reg, fat }); + const fat_path = try std.fmt.bufPrintSentinel(&fat_buf, "{s}/{s}", .{ reg, fat }, 0); { var f = try Io.Dir.createFileAbsolute(io, fat_path, .{}); f.close(io); @@ -974,10 +974,10 @@ test "post long name: max_name_len posts, probes, dials and unposts" { // scratch directory of its own. const io = testing.io; var xdg_buf: [64]u8 = undefined; - const xdg = try std.fmt.bufPrintZ(&xdg_buf, "/tmp/.p9t{d}", .{linux.getpid()}); + const xdg = try std.fmt.bufPrintSentinel(&xdg_buf, "/tmp/.p9t{d}", .{linux.getpid()}, 0); _ = try Io.Dir.createDirPathStatus(.cwd(), io, xdg, .fromMode(0o700)); var env_buf: [96]u8 = undefined; - const value = try std.fmt.bufPrintZ(&env_buf, "XDG_RUNTIME_DIR={s}", .{xdg}); + const value = try std.fmt.bufPrintSentinel(&env_buf, "XDG_RUNTIME_DIR={s}", .{xdg}, 0); const env = [2]?[*:0]const u8{ @ptrCast(value.ptr), null }; const envp: Env = @ptrCast(&env); var dbuf: [std.fs.max_path_bytes]u8 = undefined; @@ -987,7 +987,7 @@ test "post long name: max_name_len posts, probes, dials and unposts" { _ = linux.rmdir(xdg.ptr); } var pbuf: [sun_path_len]u8 = undefined; - const name = "l" ** max_name_len; + const name: []const u8 = &@as([max_name_len]u8, @splat('l')); try testing.expect(legalName(name)); var p = try post(io, envp, name, 4, &pbuf); try testing.expect(probe(p.path) == .live); @@ -996,7 +996,7 @@ test "post long name: max_name_len posts, probes, dials and unposts" { unpost(io, p.path, p.inode); p.server.deinit(io); // One past the cap is not even a path. - const too_long = "l" ** (max_name_len + 1); + const too_long: []const u8 = &@as([max_name_len + 1]u8, @splat('l')); try testing.expect(!legalName(too_long)); try testing.expectError(error.IllegalName, registryPath(envp, too_long, &pbuf)); } @@ -1021,7 +1021,7 @@ test "post watch: queue overflow surfaces, a deleted registry is gone" { var name_buf: [std.fs.max_path_bytes]u8 = undefined; const spam = 20000; for (0..spam) |i| { - const p = try std.fmt.bufPrintZ(&name_buf, "{s}/q{d}", .{ reg, i }); + const p = try std.fmt.bufPrintSentinel(&name_buf, "{s}/q{d}", .{ reg, i }, 0); var f = try Io.Dir.createFileAbsolute(io, p, .{}); f.close(io); } @@ -1049,7 +1049,7 @@ test "post watch: queue overflow surfaces, a deleted registry is gone" { _ = try Io.Dir.createDirPathStatus(.cwd(), io, reg, .fromMode(0o750)); try w.add(reg); { - var f = try Io.Dir.createFileAbsolute(io, try std.fmt.bufPrintZ(&name_buf, "{s}/back", .{reg}), .{}); + var f = try Io.Dir.createFileAbsolute(io, try std.fmt.bufPrintSentinel(&name_buf, "{s}/back", .{reg}, 0), .{}); f.close(io); } const back = try w.next(); @@ -1091,7 +1091,7 @@ test "post dialPath: refused, missing, non-socket, loop and a CLOEXEC stream" { // A live socket: dialPath yields a blocking, close-on-exec stream // (the mounted PROGRAM must not inherit a dialed descriptor). - const sock_path = try std.fmt.bufPrintZ(&path_buf, "{s}/live.sock", .{root}); + const sock_path = try std.fmt.bufPrintSentinel(&path_buf, "{s}/live.sock", .{root}, 0); var server = try (try Io.net.UnixAddress.init(sock_path)).listen(io, .{}); { var st = try dialPath(io, sock_path); @@ -1104,13 +1104,13 @@ test "post dialPath: refused, missing, non-socket, loop and a CLOEXEC stream" { try testing.expectError(error.Stale, dialPath(io, sock_path)); // No entry at all. - try testing.expectError(error.NotPosted, dialPath(io, try std.fmt.bufPrintZ(&path_buf, "{s}/missing", .{root}))); + try testing.expectError(error.NotPosted, dialPath(io, try std.fmt.bufPrintSentinel(&path_buf, "{s}/missing", .{root}, 0))); // An entry that is not a socket answers the same ECONNREFUSED the // kernel gives a dead socket; the caller tells them apart by stat // before dialing (post.post does exactly that). - try testing.expectError(error.Stale, dialPath(io, try std.fmt.bufPrintZ(&path_buf, "{s}", .{root}))); - const file_path = try std.fmt.bufPrintZ(&path_buf, "{s}/plain", .{root}); + try testing.expectError(error.Stale, dialPath(io, try std.fmt.bufPrintSentinel(&path_buf, "{s}", .{root}, 0))); + const file_path = try std.fmt.bufPrintSentinel(&path_buf, "{s}/plain", .{root}, 0); { var f = try Io.Dir.createFileAbsolute(io, file_path, .{}); f.close(io); @@ -1118,7 +1118,7 @@ test "post dialPath: refused, missing, non-socket, loop and a CLOEXEC stream" { try testing.expectError(error.Stale, dialPath(io, file_path)); // A symlink loop is its own error, not a missing entry. - const loop_path = try std.fmt.bufPrintZ(&path_buf, "{s}/loop", .{root}); + const loop_path = try std.fmt.bufPrintSentinel(&path_buf, "{s}/loop", .{root}, 0); try Io.Dir.symLinkAbsolute(io, loop_path, loop_path, .{}); try testing.expectError(error.SymLinkLoop, dialPath(io, loop_path)); } @@ -1132,12 +1132,12 @@ test "post postedDir: a 1000-entry directory lists fully or refuses cleanly" { var real_buf: [std.fs.max_path_bytes]u8 = undefined; const rlen = try s.dir.dir.realPath(io, &real_buf); var dir_buf: [std.fs.max_path_bytes]u8 = undefined; - const dir = try std.fmt.bufPrintZ(&dir_buf, "{s}", .{real_buf[0..rlen]}); + const dir = try std.fmt.bufPrintSentinel(&dir_buf, "{s}", .{real_buf[0..rlen]}, 0); for (0..1000) |i| { var name_buf: [32]u8 = undefined; var path_buf: [std.fs.max_path_bytes]u8 = undefined; const name = try std.fmt.bufPrint(&name_buf, "e{d:0>4}", .{i}); - var f = try Io.Dir.createFileAbsolute(io, try std.fmt.bufPrintZ(&path_buf, "{s}/{s}", .{ dir, name }), .{}); + var f = try Io.Dir.createFileAbsolute(io, try std.fmt.bufPrintSentinel(&path_buf, "{s}/{s}", .{ dir, name }, 0), .{}); f.close(io); } // A staging buffer that cannot hold every record is an explicit diff --git a/src/quic.zig b/src/quic.zig index c78a79d..c372e0a 100644 --- a/src/quic.zig +++ b/src/quic.zig @@ -248,7 +248,7 @@ pub fn Quic(comptime ssl: type, comptime protocol: []const u8) type { switch (address) { .ip4 => |ip| { const addr: *libc.sockaddr.in = @ptrCast(out); - addr.* = .{ .port = std.mem.nativeToBig(u16, ip.port), .addr = @bitCast(ip.bytes) }; + addr.* = .{ .port = std.mem.nativeToBig(u16, ip.port), .addr = std.mem.bytesToValue(u32, &ip.bytes) }; return @sizeOf(libc.sockaddr.in); }, .ip6 => |ip| { diff --git a/src/serve.zig b/src/serve.zig index 5166b5f..ad774a3 100644 --- a/src/serve.zig +++ b/src/serve.zig @@ -1126,7 +1126,7 @@ test "serve: listenPosted serves the registry name and stop() unposts" { var real_buf: [std.fs.max_path_bytes]u8 = undefined; const len = try rig.dir.dir.realPath(io, &real_buf); var env_buf: [std.fs.max_path_bytes]u8 = undefined; - const value = try std.fmt.bufPrintZ(&env_buf, "XDG_RUNTIME_DIR={s}", .{real_buf[0..len]}); + const value = try std.fmt.bufPrintSentinel(&env_buf, "XDG_RUNTIME_DIR={s}", .{real_buf[0..len]}, 0); const env = [2]?[*:0]const u8{ @ptrCast(value.ptr), null }; const envp: post.Env = @ptrCast(&env); @@ -1171,7 +1171,7 @@ test "serve: a second listenPosted is refused; stop() never unposts another's na var real_buf: [std.fs.max_path_bytes]u8 = undefined; const len = try rig.dir.dir.realPath(io, &real_buf); var env_buf: [std.fs.max_path_bytes]u8 = undefined; - const value = try std.fmt.bufPrintZ(&env_buf, "XDG_RUNTIME_DIR={s}", .{real_buf[0..len]}); + const value = try std.fmt.bufPrintSentinel(&env_buf, "XDG_RUNTIME_DIR={s}", .{real_buf[0..len]}, 0); const env = [2]?[*:0]const u8{ @ptrCast(value.ptr), null }; const envp: post.Env = @ptrCast(&env); @@ -1209,7 +1209,7 @@ test "serve: listenPosted beside listen(): stop unposts only the registry name" var real_buf: [std.fs.max_path_bytes]u8 = undefined; const len = try rig.dir.dir.realPath(io, &real_buf); var env_buf: [std.fs.max_path_bytes]u8 = undefined; - const value = try std.fmt.bufPrintZ(&env_buf, "XDG_RUNTIME_DIR={s}", .{real_buf[0..len]}); + const value = try std.fmt.bufPrintSentinel(&env_buf, "XDG_RUNTIME_DIR={s}", .{real_buf[0..len]}, 0); const env = [2]?[*:0]const u8{ @ptrCast(value.ptr), null }; const envp: post.Env = @ptrCast(&env); @@ -1218,7 +1218,7 @@ test "serve: listenPosted beside listen(): stop unposts only the registry name" // A plain Unix listener (the application's path policy) beside the // posted name: both listener slots fill. var unix_buf: [std.fs.max_path_bytes]u8 = undefined; - const unix_path = try std.fmt.bufPrintZ(&unix_buf, "{s}/plain.sock", .{real_buf[0..len]}); + const unix_path = try std.fmt.bufPrintSentinel(&unix_buf, "{s}/plain.sock", .{real_buf[0..len]}, 0); _ = try rig.runner.listen(.{ .unix = unix_path }, 4); try rig.runner.listenPosted(envp, "mixed", 4); @@ -1419,7 +1419,7 @@ test "serve: every descriptor opened by the post/serve path is close-on-exec" { var real_buf: [std.fs.max_path_bytes]u8 = undefined; const rlen = try dir.dir.realPath(io, &real_buf); var env_buf: [std.fs.max_path_bytes]u8 = undefined; - const value = try std.fmt.bufPrintZ(&env_buf, "XDG_RUNTIME_DIR={s}", .{real_buf[0..rlen]}); + const value = try std.fmt.bufPrintSentinel(&env_buf, "XDG_RUNTIME_DIR={s}", .{real_buf[0..rlen]}, 0); const env = [2]?[*:0]const u8{ @ptrCast(value.ptr), null }; const envp: post.Env = @ptrCast(&env); diff --git a/src/transport.zig b/src/transport.zig index d7619be..c75aa3b 100644 --- a/src/transport.zig +++ b/src/transport.zig @@ -67,7 +67,7 @@ pub fn ipSockaddr(ip: std.Io.net.IpAddress, out: *libc.sockaddr.storage) libc.so return switch (ip) { .ip4 => |a| blk: { const addr: *libc.sockaddr.in = @ptrCast(out); - addr.* = .{ .port = std.mem.nativeToBig(u16, a.port), .addr = @bitCast(a.bytes) }; + addr.* = .{ .port = std.mem.nativeToBig(u16, a.port), .addr = std.mem.bytesToValue(u32, &a.bytes) }; break :blk @sizeOf(libc.sockaddr.in); }, .ip6 => |a| blk: { diff --git a/src/wire.zig b/src/wire.zig index e093450..05bc32c 100644 --- a/src/wire.zig +++ b/src/wire.zig @@ -45,7 +45,7 @@ pub const Type = enum(u8) { }; pub fn isT(t: Type) bool { - return @intFromEnum(t) % 2 == 0; + return @backingInt(t) % 2 == 0; } pub const header_len: usize = 4 + 1 + 2; @@ -85,7 +85,7 @@ comptime { assert(qid_len == 13); assert(stat_fixed == 49); for (std.enums.values(Type)) |t| { - const even = @intFromEnum(t) % 2 == 0; + const even = @backingInt(t) % 2 == 0; assert(isT(t) == even); assert(std.mem.startsWith(u8, @tagName(t), if (even) "t" else "r")); } @@ -320,7 +320,7 @@ pub fn encode(msg: Msg, tag: u16, buf: []u8) Error![]u8 { var w: Writer = .init(buf[0..total]); try w.putU32(@intCast(total)); - try w.putByte(@intFromEnum(msg.msgType())); + try w.putByte(@backingInt(msg.msgType())); try w.putU16(tag); switch (msg) { @@ -420,7 +420,7 @@ pub fn decode(bytes: []const u8) Error!Decoded { if (size > bytes.len) return error.Truncated; if (size < bytes.len) return error.Trailing; - const t: Type = @enumFromInt(bytes[4]); + const t: Type = @fromBackingInt(@intCast(bytes[4])); const tag = std.mem.readInt(u16, bytes[5..7], .little); var r: Reader = .init(bytes[header_len..size]); @@ -724,14 +724,14 @@ const sample_stat: Stat = .{ }; test "9p: the type numbers and their parity are the protocol's own" { - try testing.expectEqual(@as(u8, 100), @intFromEnum(Type.tversion)); - try testing.expectEqual(@as(u8, 106), @intFromEnum(Type.terror)); - try testing.expectEqual(@as(u8, 107), @intFromEnum(Type.rerror)); - try testing.expectEqual(@as(u8, 126), @intFromEnum(Type.twstat)); - try testing.expectEqual(@as(u8, 127), @intFromEnum(Type.rwstat)); + try testing.expectEqual(@as(u8, 100), @backingInt(Type.tversion)); + try testing.expectEqual(@as(u8, 106), @backingInt(Type.terror)); + try testing.expectEqual(@as(u8, 107), @backingInt(Type.rerror)); + try testing.expectEqual(@as(u8, 126), @backingInt(Type.twstat)); + try testing.expectEqual(@as(u8, 127), @backingInt(Type.rwstat)); try testing.expectEqual(@as(usize, 28), std.enums.values(Type).len); - for (std.enums.values(Type), 100..) |t, want| try testing.expectEqual(@as(u8, @intCast(want)), @intFromEnum(t)); + for (std.enums.values(Type), 100..) |t, want| try testing.expectEqual(@as(u8, @intCast(want)), @backingInt(t)); try testing.expect(isT(.tversion)); try testing.expect(!isT(.rversion)); @@ -814,8 +814,8 @@ test "9p: every message round-trips" { _ = try roundTrip(&buf, 13, .{ .twstat = .{ .fid = 1, .stat = sample_stat } }); _ = try roundTrip(&buf, 13, .rwstat); - try testing.expectEqual(@as(usize, 27), @typeInfo(Msg).@"union".fields.len); - try testing.expectEqual(std.enums.values(Type).len - 1, @typeInfo(Msg).@"union".fields.len); + try testing.expectEqual(@as(usize, 27), @typeInfo(Msg).@"union".field_names.len); + try testing.expectEqual(std.enums.values(Type).len - 1, @typeInfo(Msg).@"union".field_names.len); } test "9p: empty and maximum-length strings survive the trip" { @@ -862,7 +862,7 @@ test "9p: Twalk carries 0, 1 and 16 elements and refuses 17" { const bad = blk: { var w: Writer = .init(&raw); try w.putU32(0); // patched below - try w.putByte(@intFromEnum(Type.twalk)); + try w.putByte(@backingInt(Type.twalk)); try w.putU16(1); try w.putU32(0); try w.putU32(1); @@ -877,7 +877,7 @@ test "9p: Twalk carries 0, 1 and 16 elements and refuses 17" { const bad_r = blk: { var w: Writer = .init(&raw); try w.putU32(0); - try w.putByte(@intFromEnum(Type.rwalk)); + try w.putByte(@backingInt(Type.rwalk)); try w.putU16(1); try w.putU16(17); for (0..17) |_| try w.putQid(sample_qid); @@ -1003,13 +1003,13 @@ test "9p: an unknown or illegal type byte is refused" { var t: u16 = 0; while (t <= 255) : (t += 1) { raw[4] = @intCast(t); - const defined = t >= 100 and t <= 127 and t != @intFromEnum(Type.terror); + const defined = t >= 100 and t <= 127 and t != @backingInt(Type.terror); if (decode(raw[0..bytes.len])) |got| { - try testing.expectEqual(@as(u8, @intCast(t)), @intFromEnum(got.msg.msgType())); - try testing.expect(t == @intFromEnum(Type.tclunk) or - t == @intFromEnum(Type.tremove) or - t == @intFromEnum(Type.tstat) or - t == @intFromEnum(Type.rwrite)); + try testing.expectEqual(@as(u8, @intCast(t)), @backingInt(got.msg.msgType())); + try testing.expect(t == @backingInt(Type.tclunk) or + t == @backingInt(Type.tremove) or + t == @backingInt(Type.tstat) or + t == @backingInt(Type.rwrite)); } else |err| { if (!defined) try testing.expectEqual(Error.BadTag, err); } @@ -1021,7 +1021,7 @@ test "9p: trailing bytes inside the size are refused" { var w: Writer = .init(&raw); try w.putU32(12); - try w.putByte(@intFromEnum(Type.tclunk)); + try w.putByte(@backingInt(Type.tclunk)); try w.putU16(1); try w.putU32(7); try w.putByte(0xAA); @@ -1030,7 +1030,7 @@ test "9p: trailing bytes inside the size are refused" { w = .init(&raw); try w.putU32(header_len + 2 + 2); - try w.putByte(@intFromEnum(Type.tflush)); + try w.putByte(@backingInt(Type.tflush)); try w.putU16(1); try w.putU16(3); try w.putU16(3); |
