commit de6c0d500fb27d01e284c047efeb4e02fb8c63e2 (tree)
parent 29e52aa0407a9b422006967f1bcc651240f9cfcf
Author: Yusuf Bham <git@fiftysix.dev>
Date: Wed, 18 Feb 2026 20:04:18 -0500
uefi(guid): don't use @byteSwap in fmt, adjust fmt test
@byteSwap shouldn't be called since we're formatting
ints again, and UEFI only officially supports LE.
Diffstat:
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/lib/std/os/uefi.zig b/lib/std/os/uefi.zig
@@ -107,14 +107,10 @@ pub const Guid = extern struct {
/// Format GUID into hexadecimal lowercase xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format
pub fn format(self: Guid, writer: *std.Io.Writer) std.Io.Writer.Error!void {
- const time_low = @byteSwap(self.time_low);
- const time_mid = @byteSwap(self.time_mid);
- const time_high_and_version = @byteSwap(self.time_high_and_version);
-
return writer.print("{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x}", .{
- time_low,
- time_mid,
- time_high_and_version,
+ self.time_low,
+ self.time_mid,
+ self.time_high_and_version,
self.clock_seq_high_and_reserved,
self.clock_seq_low,
self.node,
@@ -225,10 +221,10 @@ test "GUID formatting" {
const bytes = [_]u8{ 137, 60, 203, 50, 128, 128, 124, 66, 186, 19, 80, 73, 135, 59, 194, 135 };
const guid: Guid = @bitCast(bytes);
- const str = try std.fmt.allocPrint(std.testing.allocator, "{}", .{guid});
+ const str = try std.fmt.allocPrint(std.testing.allocator, "{f}", .{guid});
defer std.testing.allocator.free(str);
- try std.testing.expect(std.mem.eql(u8, str, "32cb3c89-8080-427c-ba13-5049873bc287"));
+ try std.testing.expectEqualStrings(str, "32cb3c89-8080-427c-ba13-5049873bc287");
}
test {