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.
This commit is contained in:
Yusuf Bham 2026-02-18 20:04:18 -05:00 committed by Alex Rønne Petersen
parent 29e52aa040
commit de6c0d500f

View file

@ -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 {