From 61740bda8526339cd4f50723d7be140938cb28c5 Mon Sep 17 00:00:00 2001 From: jfreegman Date: Thu, 26 Nov 2020 18:25:37 -0500 Subject: [PATCH] Fix a couple minor issues Print a warning if remove() fails, and check if the win pointer is null before using it (this is unnecessary but it's correct and shuts coverity up) --- src/line_info.c | 5 ++++- src/log.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/line_info.c b/src/line_info.c index 26f61d7..701411a 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -242,7 +242,10 @@ static void print_wrap(WINDOW *win, struct line_info *line, int max_x) print_n_chars(win, msg, space_idx); msg += space_idx + 1; length -= (space_idx + 1); - waddch(win, '\n'); + + if (win) { + waddch(win, '\n'); + } } else { print_n_chars(win, msg, x_limit); msg += x_limit; diff --git a/src/log.c b/src/log.c index c15e52f..540a389 100644 --- a/src/log.c +++ b/src/log.c @@ -358,7 +358,9 @@ int rename_logfile(const char *src, const char *dest, const char *selfkey, const } if (file_exists(newpath)) { - remove(oldpath); + if (remove(oldpath) != 0) { + fprintf(stderr, "Warning: remove() failed to remove log path `%s`\n", oldpath); + } } else if (rename(oldpath, newpath) != 0) { goto on_error; }