From 024e456ddadd67f212d84665501869c568a106fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 8 Nov 2015 17:10:47 +0100 Subject: Fix warnings found by static analyzer --- ui-curses.c | 4 ++-- ui.h | 2 +- view.c | 3 +-- vis.h | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ui-curses.c b/ui-curses.c index 7e30dbc..ef397c0 100644 --- a/ui-curses.c +++ b/ui-curses.c @@ -672,7 +672,7 @@ static void ui_window_draw(UiWin *w) { } short selection_bg = win->styles[UI_STYLE_SELECTION].bg; short cursor_line_bg = win->styles[UI_STYLE_CURSOR_LINE].bg; - attr_t attr; + attr_t attr = A_NORMAL; for (const Line *l = view_lines_get(win->view); l; l = l->next) { bool cursor_line = l->lineno == cursor_lineno; for (int x = 0; x < width; x++) { @@ -919,7 +919,7 @@ static UiWin *ui_window_new(Ui *ui, View *view, File *file) { return &win->uiwin; } -static void ui_die(Ui *ui, const char *msg, va_list ap) { +__attribute__((noreturn)) static void ui_die(Ui *ui, const char *msg, va_list ap) { UiCurses *uic = (UiCurses*)ui; endwin(); if (uic->termkey) diff --git a/ui.h b/ui.h index 621342d..7e04d09 100644 --- a/ui.h +++ b/ui.h @@ -50,7 +50,7 @@ struct Ui { void (*prompt)(Ui*, const char *title, const char *value); char* (*prompt_input)(Ui*); void (*prompt_hide)(Ui*); - void (*die)(Ui*, const char *msg, va_list ap); + void (*die)(Ui*, const char *msg, va_list ap) __attribute__((noreturn)); void (*info)(Ui*, const char *msg, va_list ap); void (*info_hide)(Ui*); void (*arrange)(Ui*, enum UiLayout); diff --git a/view.c b/view.c index 8931301..542a9e1 100644 --- a/view.c +++ b/view.c @@ -599,8 +599,7 @@ bool view_resize(View *view, int width, int height) { } view->width = width; view->height = height; - if (view->lines) - memset(view->lines, 0, view->lines_size); + memset(view->lines, 0, view->lines_size); view_draw(view); return true; } diff --git a/vis.h b/vis.h index 80b3f3b..0399d3c 100644 --- a/vis.h +++ b/vis.h @@ -104,7 +104,7 @@ int vis_run(Vis*, int argc, char *argv[]); /* terminate editing session, given status will be the return value of vis_run */ void vis_exit(Vis*, int status); /* emergency exit, print given message, perform minimal ui cleanup and exit process */ -void vis_die(Vis*, const char *msg, ...); +void vis_die(Vis*, const char *msg, ...) __attribute__((noreturn)); /* user facing modes are: NORMAL, VISUAL, VISUAL_LINE, PROMPT, INSERT, REPLACE. * the others should be considered as implementation details (TODO: do not expose them?) */ -- cgit v1.2.3