summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 12:38:55 -0300
committerGabriel Schneider <[email protected]>2026-11-06 14:56:36 -0300
commitdde4979f59bec754b7909a81a40763850f3c29c0 (patch)
treec885f4ddc37f0564b4b20345c1a0f02672663252 /src/gui
parent4c194047d210ad9cf571c6019731d00d1e3615a4 (diff)
downloadpardes-dde4979f59bec754b7909a81a40763850f3c29c0.tar.gz
pardes-dde4979f59bec754b7909a81a40763850f3c29c0.zip
idioms #5, more formats that cannot overflow: /proc paths of a pid, the daemon's pty, close and clients words, a pid or a serial for the environment, a capture's header and status line and a cache's .new name are catch unreachable with their reason, where a catch return, null or continue stood for an overflow no buffer here can have
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index c149d913..d2e17508 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -7165,7 +7165,7 @@ fn writeTestStatus(g: *const Gui, core: *const pardes.Pardes, presented: bool) v
!g.glide.moving() and g.scroll_lag == 0 and g.scroll_delta == 0 and g.scroll_notch == 0;
var line_buf: [64]u8 = undefined;
// What keeps it busy, after: owes a frame, moves, waits, not shown.
- const line = std.fmt.bufPrint(&line_buf, "{d} {d} {d} {d}{d}{d}{d}\n", .{ test_status_step, g.captured, @intFromBool(idle), @intFromBool(core.needs_frame), @intFromBool(frontendMoving(g)), @intFromBool(core.nextWake() != null), @intFromBool(!presented) }) catch return;
+ const line = std.fmt.bufPrint(&line_buf, "{d} {d} {d} {d}{d}{d}{d}\n", .{ test_status_step, g.captured, @intFromBool(idle), @intFromBool(core.needs_frame), @intFromBool(frontendMoving(g)), @intFromBool(core.nextWake() != null), @intFromBool(!presented) }) catch unreachable; // seven numbers fit 64
var tmp_buf: [4096]u8 = undefined;
var final_buf: [4096]u8 = undefined;
const tmp_path = std.fmt.bufPrintSentinel(&tmp_buf, "{s}/status.tmp", .{g.capture_dir}, 0) catch return;
@@ -7199,7 +7199,7 @@ fn writeCapturePpm(g: *Gui, gpa: std.mem.Allocator, pixels: []const u8, width: u
defer _ = libc.close(fd);
var header: [64]u8 = undefined;
- const hdr = std.fmt.bufPrint(&header, "P6\n{d} {d}\n255\n", .{ width, height }) catch return error.CaptureWriteFailed;
+ const hdr = std.fmt.bufPrint(&header, "P6\n{d} {d}\n255\n", .{ width, height }) catch unreachable; // two u32s fit 64
_ = host_io.writeFd(fd, hdr);
const row_rgb = try gpa.alloc(u8, @as(usize, width) * 3);