diff --git a/src/config.zig b/src/config.zig index a793da2..8bb7cd9 100644 --- a/src/config.zig +++ b/src/config.zig @@ -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 } @@ -209,7 +209,7 @@ test "read" { if (ret) { assert(true); } else |err| { - warn("warn: {}\n", .{err}); + warn("warn: {!}\n", .{err}); assert(false); } } diff --git a/src/db/file.zig b/src/db/file.zig index 7daa851..e8f4996 100644 --- a/src/db/file.zig +++ b/src/db/file.zig @@ -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; } @@ -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 }); } } diff --git a/src/gui/libui.zig b/src/gui/libui.zig index c529c78..6454f1a 100644 --- a/src/gui/libui.zig +++ b/src/gui/libui.zig @@ -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; } } diff --git a/src/main.zig b/src/main.zig index feab007..0d13095 100644 --- a/src/main.zig +++ b/src/main.zig @@ -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}); } } @@ -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}); } } diff --git a/src/net.zig b/src/net.zig index 12a0404..a19a853 100644 --- a/src/net.zig +++ b/src/net.zig @@ -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; @@ -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; @@ -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; } diff --git a/src/thread.zig b/src/thread.zig index cacf9d5..ef50aa5 100644 --- a/src/thread.zig +++ b/src/thread.zig @@ -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; } diff --git a/src/util.zig b/src/util.zig index 204bcbc..e8506eb 100644 --- a/src/util.zig +++ b/src/util.zig @@ -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; }