From fd1cab251d52bea00484a4b3cf8ae7f5072446de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sat, 19 Feb 2022 15:48:51 +0200 Subject: [PATCH] fix shell index offsets --- src/shell.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shell.zig b/src/shell.zig index 0534d6d..d17c2b3 100644 --- a/src/shell.zig +++ b/src/shell.zig @@ -17,7 +17,7 @@ pub const ShellReader = struct { pub fn init(index: []const u8, blob: []const u8) ShellReader { return ShellReader{ - .sectionIndex = @bitCast([]const ShellIndex, index), + .sectionIndex = std.mem.bytesAsSlice(ShellIndex, index), .sectionBlob = blob, }; } @@ -78,7 +78,7 @@ pub const ShellWriter = struct { } pub fn sectionIndex(self: *const ShellSections) []const u8 { - return @bitCast([]const u8, self.index.constSlice()); + return std.mem.sliceAsBytes(self.index.constSlice()); } pub fn sectionBlob(self: *const ShellSections) []const u8 { @@ -176,7 +176,7 @@ inline fn roundUp4Padding(n: u12) u12 { // to 4 bytes. // The actual shell length is len+1: we don't allow empty shells, and the real // length of the shell is 1-64 bytes. -const ShellIndex = struct { +const ShellIndex = packed struct { offset: u10, len: u6, };