From 0b58ebbea977f34c5192ae6f0caec31f66749e9e Mon Sep 17 00:00:00 2001 From: pommicket Date: Fri, 22 Jul 2022 14:59:24 -0400 Subject: fixed some compiler warnings --- main.c | 14 ++++++++++---- ui.c | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 557a1ea..63b7ad7 100644 --- a/main.c +++ b/main.c @@ -507,11 +507,17 @@ int main(int argc, char **argv) { { if (starting_filename) { if (fs_file_exists(starting_filename)) { - if (!ted_open_file(ted, starting_filename)) - ted_seterr(ted, "Couldn't load file: %s", ted_geterr(ted)); + if (!ted_open_file(ted, starting_filename)) { + char err[512] = {0}; + sprintf(err, "%.500s", ted_geterr(ted)); // -Wrestrict (rightly) complains without this intermediate step + ted_seterr(ted, "Couldn't load file: %s", err); + } } else { - if (!ted_new_file(ted, starting_filename)) - ted_seterr(ted, "Couldn't create file: %s", ted_geterr(ted)); + if (!ted_new_file(ted, starting_filename)) { + char err[512] = {0}; + sprintf(err, "%.500s", ted_geterr(ted)); + ted_seterr(ted, "Couldn't create file: %s", err); + } } } else { session_read(ted); diff --git a/ui.c b/ui.c index 993a51f..55132a5 100644 --- a/ui.c +++ b/ui.c @@ -588,7 +588,7 @@ static void popup_get_rects(Ted const *ted, u32 options, Rect *popup, Rect *butt } static PopupOption popup_update(Ted *ted, u32 options) { - Rect r, button_yes, button_no, button_cancel; + Rect r = {0}, button_yes = {0}, button_no = {0}, button_cancel = {0}; popup_get_rects(ted, options, &r, &button_yes, &button_no, &button_cancel); if (button_update(ted, button_yes)) return POPUP_YES; -- cgit v1.2.3