Skip to content

Commit

Permalink
mysterious {} err
Browse files Browse the repository at this point in the history
  • Loading branch information
donpdonp committed Jul 9, 2024
1 parent ce8968f commit acd3169
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub fn writefile(settings: Settings, filename: []const u8) void {
warn("config saved. {s} {} bytes\n", .{ filename, file.getPos() });
file.close();
} else |err| {
warn("config save fail. {}\n", .{err});
warn("config save fail. {!}\n", .{err});
} // existing file is OK
}

Expand All @@ -209,7 +209,7 @@ test "read" {
if (ret) {
assert(true);
} else |err| {
warn("warn: {}\n", .{err});
warn("warn: {!}\n", .{err});
assert(false);
}
}
4 changes: 2 additions & 2 deletions src/db/file.zig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn has(namespace: []const u8, key: []const u8, allocator: Allocator) bool {
if (std.fs.cwd().access(keypath, .{ .mode = .read_only })) {
found = true;
} else |err| {
warn("dbfile did not find {s} {}\n", .{ keypath, err });
warn("dbfile did not find {s} {!}\n", .{ keypath, err });
}
return found;
}
Expand All @@ -38,6 +38,6 @@ pub fn write(namespace: []const u8, key: []const u8, value: []const u8, allocato
_ = try file.write(value);
file.close();
} else |err| {
warn("open write err {s} {s} {}\n", .{ dirpath, key, err });
warn("open write err {s} {s} {!}\n", .{ dirpath, key, err });
}
}
2 changes: 1 addition & 1 deletion src/gui/libui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn gui_setup(actor: *thread.Actor) !void {
if (err == 0) {
build();
} else {
warn("libui init failed {}\n", err);
warn("libui init failed {!}\n", err);
return GUIError.Init;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn main() !void {
thread.wait(); // main ipc listener
}
} else |err| {
log.err("config error: {}\n", .{err});
log.err("config error: {!}\n", .{err});
}
}

Expand Down Expand Up @@ -99,8 +99,8 @@ fn columnget(column: *config.ColumnInfo, allocator: std.mem.Allocator) void {
httpInfo.response_code = 0;
verb.http = httpInfo;
gui.schedule(gui.update_column_netstatus_schedule, @as(*anyopaque, @ptrCast(httpInfo)));
if (thread.create("net", net.go, verb, netback)) {} else |err| {
warn("columnget {}", .{err});
if (thread.create("net", net.go, verb, netback)) |_| {} else |err| {
warn("columnget {!}", .{err});
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/net.zig
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ pub fn go(data: ?*anyopaque) callconv(.C) ?*anyopaque {
defer value_tree.deinit();
actor.payload.http.tree = value_tree.value;
} else |err| {
warn("net json err {}\n", .{err});
warn("net json err {!}\n", .{err});
actor.payload.http.response_code = 1000;
}
}
} else |err| {
warn("net thread http err {}\n", .{err});
warn("net thread http err {!}\n", .{err});
}
thread.signal(actor, command);
return null;
Expand Down Expand Up @@ -97,7 +97,7 @@ pub fn httpget(req: *config.HttpInfo) ![]const u8 {
return NetError.Curl;
} else {
const err_cstr = c.curl_easy_strerror(res);
warn("curl ERR {} {s}\n", .{ res, util.cstrToSliceCopy(allocator, err_cstr) });
warn("curl ERR {!} {s}\n", .{ res, util.cstrToSliceCopy(allocator, err_cstr) });
if (res == c.CURLE_COULDNT_RESOLVE_HOST) {
req.response_code = 2100;
return NetError.DNS;
Expand All @@ -112,11 +112,11 @@ pub fn httpget(req: *config.HttpInfo) ![]const u8 {
}
}

pub fn curl_write(ptr: [*c]const u8, _: usize, nmemb: usize, userdata: *anyopaque) usize {
pub fn curl_write(ptr: [*c]const u8, _: usize, nmemb: usize, userdata: *anyopaque) callconv(.C) usize {
var buf = @as(*std.ArrayList(u8), @ptrCast(@alignCast(userdata)));
const body_part: []const u8 = ptr[0..nmemb];
buf.appendSlice(body_part) catch |err| {
warn("curl_write append fail {}\n", .{err});
warn("curl_write append fail {!}\n", .{err});
};
return nmemb;
}
2 changes: 1 addition & 1 deletion src/thread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn create(
if (pt_err == 0) {
return actor;
} else {
warn("ERROR thread pthread_create err: {} {}\n", .{ pt_err, actor });
warn("ERROR thread pthread_create err: {!} {*}\n", .{ pt_err, actor });
}
return error.BadValue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn sliceToCstr(allocator: Allocator, str: []const u8) [*]u8 {
pub fn cstrToSliceCopy(allocator: Allocator, cstr: [*c]const u8) []const u8 {
const i: usize = std.mem.len(cstr);
const ram = allocator.alloc(u8, i) catch unreachable;
std.mem.copy(u8, ram, cstr[0..i]);
std.mem.copyForwards(u8, ram, cstr[0..i]);
return ram;
}

Expand Down

0 comments on commit acd3169

Please sign in to comment.