summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/9p_io.zig2
-rw-r--r--src/Handover.zig5
-rw-r--r--src/daemon.zig19
-rw-r--r--src/dump.zig6
-rw-r--r--src/gui/gui.zig4
-rw-r--r--src/host_io.zig4
-rw-r--r--src/upgrade.zig4
7 files changed, 23 insertions, 21 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig
index 70bd0bbf..72548d2a 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -355,7 +355,7 @@ pub const Listener = struct {
const refused = l.refused.swap(0, .acq_rel);
if (refused != 0) {
var why: [64]u8 = undefined;
- pardes.ctlfs.events.notePath(core, "err -", std.fmt.bufPrint(&why, "9p: too many connections ({d} turned away)", .{refused}) catch "9p: too many connections");
+ pardes.ctlfs.events.notePath(core, "err -", std.fmt.bufPrint(&why, "9p: too many connections ({d} turned away)", .{refused}) catch unreachable); // a u32 fits 64
}
if (!core.fs.news) return;
core.fs.news = false;
diff --git a/src/Handover.zig b/src/Handover.zig
index 23baf4ad..e9e0622b 100644
--- a/src/Handover.zig
+++ b/src/Handover.zig
@@ -217,7 +217,8 @@ fn dumpCarried(p: *Pardes, kind: Kind, at: usize, ids: []const usize, seq: u32)
}
}{ .w = &w, .value = &value });
var name: [32]u8 = undefined;
- return pardes.Db.image(p.gpa, std.fmt.bufPrint(&name, "handover-{d}", .{seq}) catch "handover", buf.written(), w.blobs.items, ids.len);
+ // "handover-" and a u32 fit 32.
+ return pardes.Db.image(p.gpa, std.fmt.bufPrint(&name, "handover-{d}", .{seq}) catch unreachable, buf.written(), w.blobs.items, ids.len);
}
/// Whether `bytes` are a handover's dump (`dumpCarried`'s, or an older
@@ -413,7 +414,7 @@ fn carry(io: std.Io, job: *Job) void {
return job.post(job.post_ctx, job.seq, false, "the new window ended before it was up");
if (ninep_io.Client.readLimit(job.gpa, entry, "status", "status", 256)) |status| {
job.gpa.free(status);
- return job.post(job.post_ctx, job.seq, true, std.fmt.bufPrint(&words, "a new window (pardes/{d})", .{pid}) catch "a new window");
+ return job.post(job.post_ctx, job.seq, true, std.fmt.bufPrint(&words, "a new window (pardes/{d})", .{pid}) catch unreachable); // a pid fits 256
} else |_| {}
io.sleep(.fromMilliseconds(50), .awake) catch {
for_child = true;
diff --git a/src/daemon.zig b/src/daemon.zig
index 6c0a0adf..ed558a52 100644
--- a/src/daemon.zig
+++ b/src/daemon.zig
@@ -759,13 +759,14 @@ const Daemon = struct {
fn kill(d: *Daemon, i: u8, named: ?[]const u8) void {
var line: [msg_max]u8 = undefined;
var w: std.Io.Writer = .fixed(&line);
- w.writeAll("ok") catch {};
+ // "ok" and max_conns pids fit msg_max.
+ w.writeAll("ok") catch unreachable;
var n: usize = 0;
for (&d.conns) |*s| if (s.fd >= 0 and s.kind != null) {
if (named) |want| if (!std.mem.eql(u8, s.named(), want)) continue;
s.killed = true;
_ = libc.kill(s.pid, .TERM);
- w.print(" {d}", .{s.pid}) catch {};
+ w.print(" {d}", .{s.pid}) catch unreachable;
n += 1;
};
if (named == null) {
@@ -783,7 +784,7 @@ const Daemon = struct {
fn list(d: *Daemon, i: u8) void {
var line: [msg_max]u8 = undefined;
var w: std.Io.Writer = .fixed(&line);
- w.print("daemon {d}\n", .{libc.getpid()}) catch {};
+ w.print("daemon {d}\n", .{libc.getpid()}) catch unreachable; // the first line of msg_max
for (&d.conns, 0..) |*s, k| if (s.fd >= 0 and s.kind != null) {
w.print("session {d} {t} {s} {s}\n", .{ s.pid, s.kind.?, if (s.detached) "detached" else "attached", s.named() }) catch break;
for (s.clients[0..s.nclients]) |pid| w.print("client {d}\n", .{pid}) catch break;
@@ -940,7 +941,7 @@ const Daemon = struct {
found = @intCast(i);
};
if (count == 1) {
- _ = std.fmt.bufPrint(why, "other {s}", .{d.conns[found.?].named()}) catch {};
+ _ = std.fmt.bufPrint(why, "other {s}", .{d.conns[found.?].named()}) catch unreachable; // a name of 128 fits 512
return null;
}
count = 0;
@@ -952,19 +953,19 @@ const Daemon = struct {
only = s;
};
if (found == null and sessions == 1) {
- _ = std.fmt.bufPrint(why, "other {s}", .{only.?.named()}) catch {};
+ _ = std.fmt.bufPrint(why, "other {s}", .{only.?.named()}) catch unreachable; // a name of 128 fits 512
return null;
}
}
if (count == 0 and others == 0) {
- w.writeAll("no no detached session is running") catch {};
+ w.writeAll("no no detached session is running") catch unreachable; // fits 511
return null;
}
if (count == 0) {
- w.print("no the detached session{s} running {s} {s}=<name>`", .{ if (others == 1) " is" else "s are", if (others == 1) "is" else "are each", other }) catch {};
+ w.print("no the detached session{s} running {s} {s}=<name>`", .{ if (others == 1) " is" else "s are", if (others == 1) "is" else "are each", other }) catch unreachable; // fits 511
return null;
}
- w.print("no {d} detached sessions are running; say which with --attach=<name>:", .{count}) catch {};
+ w.print("no {d} detached sessions are running; say which with --attach=<name>:", .{count}) catch unreachable; // fits 511
for (&d.conns) |*s| if (s.fd >= 0 and s.detached and s.kind == k) {
w.print(" {s}", .{s.named()}) catch {};
};
@@ -989,7 +990,7 @@ const Daemon = struct {
if (f.tag != @backingInt(wire.ClientTag.hello)) return refuse(r, "the first message is not a hello");
var why: [512]u8 = undefined;
const v = wire.helloVersion(f.payload) catch 0;
- if (v != wire.version) return refuse(r, std.fmt.bufPrint(&why, "this client speaks replica protocol {d}, and this daemon {d}: run the same pardes at both ends", .{ v, wire.version }) catch "another protocol");
+ if (v != wire.version) return refuse(r, std.fmt.bufPrint(&why, "this client speaks replica protocol {d}, and this daemon {d}: run the same pardes at both ends", .{ v, wire.version }) catch unreachable); // two numbers fit 512
const h = (wire.decodeClient(f.tag, f.payload) catch return refuse(r, "a malformed hello")).hello;
const target = for (&d.conns, 0..) |*c, i| {
if (c.fd >= 0 and c.kind != null and std.mem.eql(u8, c.named(), h.session)) break i;
diff --git a/src/dump.zig b/src/dump.zig
index ba159325..82b1410f 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -247,14 +247,14 @@ fn dumpWith(p: *Pardes, deferred: ?*std.ArrayListUnmanaged(walk.Deferred)) ![]u8
/// Whether `bytes` are a dump a Restore could read, saying nothing: a
/// Restore asks before it warns about unsaved text or replaces anything.
/// Why not is left in `why`, ended by a 0.
-pub fn check(gpa: std.mem.Allocator, bytes: []const u8, why: []u8) !void {
+pub fn check(gpa: std.mem.Allocator, bytes: []const u8, why: *[256]u8) !void {
if (pardes.Db.isImage(bytes)) {
const r = pardes.Db.Read.open(gpa, bytes, null) catch |err| {
const said = std.fmt.bufPrint(why[0 .. why.len - 1], "{s}", .{switch (err) {
error.NoDump => "it holds no dump",
error.OutOfMemory => "out of memory",
else => "it is no dump of pardes's",
- }}) catch "";
+ }}) catch unreachable; // a short phrase or an error's name fits 255
why[said.len] = 0;
return err;
};
@@ -266,7 +266,7 @@ pub fn check(gpa: std.mem.Allocator, bytes: []const u8, why: []u8) !void {
error.BadDump => "it does not begin as one",
error.EndOfDump => "it is cut short",
else => @errorName(err),
- }}) catch "";
+ }}) catch unreachable; // a short phrase or an error's name fits 255
why[said.len] = 0;
return err;
};
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 8271699e..48a30b8d 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -3721,7 +3721,7 @@ fn captureSeries(dir: []const u8, pixels: []const u8, w: u32, h: u32) void {
const tf = libc.open(times, .{ .ACCMODE = .WRONLY, .CREAT = true, .APPEND = true }, @as(libc.mode_t, 0o644));
if (tf < 0) return;
var line_buf: [96]u8 = undefined;
- const line = std.fmt.bufPrint(&line_buf, "{d} {d} {d} {d}\n", .{ frame_capture_count, monoNs(), w, h }) catch "";
+ const line = std.fmt.bufPrint(&line_buf, "{d} {d} {d} {d}\n", .{ frame_capture_count, monoNs(), w, h }) catch unreachable; // four numbers fit 96
_ = libc.write(tf, line.ptr, line.len);
_ = libc.close(tf);
frame_capture_count += 1;
@@ -4219,7 +4219,7 @@ fn handOver(ctx: ?*anyopaque, seq: u32, bytes: []const u8) void {
const geometry = (if (placed)
std.fmt.bufPrint(&job.geometry, "{d}x{d}+{d}+{d}", .{ w, h, @as(i32, @intFromFloat(gx)) - 40, @as(i32, @intFromFloat(gy)) - 10 })
else
- std.fmt.bufPrint(&job.geometry, "{d}x{d}", .{ w, h })) catch "";
+ std.fmt.bufPrint(&job.geometry, "{d}x{d}", .{ w, h })) catch unreachable; // four c_ints fit 64
job.geometry_len = geometry.len;
}
s.core.handover.start(s.io, job) catch |err| {
diff --git a/src/host_io.zig b/src/host_io.zig
index a363a578..3fed6e1d 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -231,7 +231,7 @@ pub const Adoptions = struct {
pub fn adoptShell(a: *Adoptions, core: *pardes.Pardes, pid: libc.pid_t, fd: c_int) void {
if (pid == 0) {
var buf: [96]u8 = undefined;
- return core.setMessage(core.view().active, if (a.taken == 0) "Adopt: no shell of a session that died is waiting" else std.fmt.bufPrint(&buf, "Adopt: {d} shell{s} taken in; what they showed is gone", .{ a.taken, if (a.taken == 1) "" else "s" }) catch "Adopt: shells taken in");
+ return core.setMessage(core.view().active, if (a.taken == 0) "Adopt: no shell of a session that died is waiting" else std.fmt.bufPrint(&buf, "Adopt: {d} shell{s} taken in; what they showed is gone", .{ a.taken, if (a.taken == 1) "" else "s" }) catch unreachable); // a count fits 96
}
if (a.len < a.list.len) {
a.list[a.len] = .{ .pid = pid, .fd = fd, .pane = null };
@@ -246,7 +246,7 @@ pub const Adoptions = struct {
// No room for it: its master goes, and the shell with this session.
_ = libc.close(fd);
var buf: [96]u8 = undefined;
- core.setMessage(core.view().active, std.fmt.bufPrint(&buf, "Adopt: no room for shell {d}; it ends with this session", .{pid}) catch "Adopt: no room for a shell");
+ core.setMessage(core.view().active, std.fmt.bufPrint(&buf, "Adopt: no room for shell {d}; it ends with this session", .{pid}) catch unreachable); // a pid fits 96
}
/// The adopted shell pane `pane`'s spawn takes, off the list.
diff --git a/src/upgrade.zig b/src/upgrade.zig
index 97d3be4f..626751ff 100644
--- a/src/upgrade.zig
+++ b/src/upgrade.zig
@@ -289,9 +289,9 @@ pub fn check(path: [:0]const u8, buf: []u8) Checked {
else if (libc.W.IFEXITED(s) and libc.W.EXITSTATUS(s) == 127)
"would not start"
else if (libc.W.IFEXITED(s) and libc.W.EXITSTATUS(s) != 0)
- std.fmt.bufPrint(&tail, "exited {d} at --version", .{libc.W.EXITSTATUS(s)}) catch "failed at --version"
+ std.fmt.bufPrint(&tail, "exited {d} at --version", .{libc.W.EXITSTATUS(s)}) catch unreachable // fits 96
else if (libc.W.IFSIGNALED(s))
- std.fmt.bufPrint(&tail, "died of signal {d} at --version", .{libc.W.TERMSIG(s)}) catch "died at --version"
+ std.fmt.bufPrint(&tail, "died of signal {d} at --version", .{libc.W.TERMSIG(s)}) catch unreachable // fits 96
else
"does not answer --version as a pardes does";
return .{ .no = std.fmt.bufPrint(buf, "Upgrade: {s} {s}; this session stays as it is", .{ path[0..@min(path.len, 400)], how }) catch "Upgrade: the new pardes would not start; this session stays as it is" };