authorgravatar for git@fiftysix.devYusuf Bham <git@fiftysix.dev> 2026-02-18 20:04:18-05:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-02-22 23:13:33+01:00
logde6c0d500fb27d01e284c047efeb4e02fb8c63e2
tree93a08e2d798b4479392f988defa9ed37d0367a33
parent29e52aa0407a9b422006967f1bcc651240f9cfcf

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.

1 files changed, 5 insertions(+), 9 deletions(-)

lib/std/os/uefi.zig+5-9
......@@ -107,14 +107,10 @@ pub const Guid = extern struct {
107107
108108 /// Format GUID into hexadecimal lowercase xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format
109109 pub fn format(self: Guid, writer: *std.Io.Writer) std.Io.Writer.Error!void {
110 const time_low = @byteSwap(self.time_low);
111 const time_mid = @byteSwap(self.time_mid);
112 const time_high_and_version = @byteSwap(self.time_high_and_version);
113
114110 return writer.print("{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x}", .{
115 time_low,
116 time_mid,
117 time_high_and_version,
111 self.time_low,
112 self.time_mid,
113 self.time_high_and_version,
118114 self.clock_seq_high_and_reserved,
119115 self.clock_seq_low,
120116 self.node,
......@@ -225,10 +221,10 @@ test "GUID formatting" {
225221 const bytes = [_]u8{ 137, 60, 203, 50, 128, 128, 124, 66, 186, 19, 80, 73, 135, 59, 194, 135 };
226222 const guid: Guid = @bitCast(bytes);
227223
228 const str = try std.fmt.allocPrint(std.testing.allocator, "{}", .{guid});
224 const str = try std.fmt.allocPrint(std.testing.allocator, "{f}", .{guid});
229225 defer std.testing.allocator.free(str);
230226
231 try std.testing.expect(std.mem.eql(u8, str, "32cb3c89-8080-427c-ba13-5049873bc287"));
227 try std.testing.expectEqualStrings(str, "32cb3c89-8080-427c-ba13-5049873bc287");
232228}
233229
234230test {