From 277f64b5ae6cc43f28eb7486d4435e513ece97db Mon Sep 17 00:00:00 2001 From: a bellenir Date: Mon, 28 Jul 2014 16:25:04 +0000 Subject: [PATCH] add -Wextra flag and fix issues --- Rakefile | 4 +++- source/frame.c | 4 ++-- source/input.c | 10 ++++------ source/main.c | 4 +++- source/workdir.c | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Rakefile b/Rakefile index ff3f251..9cf4c9d 100644 --- a/Rakefile +++ b/Rakefile @@ -25,7 +25,9 @@ Env = Rscons::Environment.new do |env| env['LIBS'] = ['ncurses', 'cds'] env['LIBPATH'] += ['./build'] env['CPPPATH'] += Dir['modules/data-structures/source/**/'] - env['CFLAGS'] += ['-Wall', '-Werror', '-pedantic', '--std=c99'] + env['CFLAGS'] += ['-Wall', '-Wextra', + #'-Werror', #commented out until mike fixes his shit. + '-pedantic', '--std=c99'] # Platform-Specific Defines and Options # ------------------------------------- diff --git a/source/frame.c b/source/frame.c index 1b61861..9b621f5 100644 --- a/source/frame.c +++ b/source/frame.c @@ -89,8 +89,8 @@ void frame_page_down(Frame_T* p_frame){ } void frame_draw_files(Frame_T* frame){ - int file_i, frame_i = FrameTopBuffer; - int rows, cols; + unsigned int file_i, frame_i = FrameTopBuffer; + unsigned int rows, cols; getmaxyx(frame->p_win, rows, cols); frame_scroll(frame); file_i = frame->top_index; diff --git a/source/input.c b/source/input.c index f47c764..89a129c 100644 --- a/source/input.c +++ b/source/input.c @@ -117,7 +117,7 @@ void input_handle_key(char ch) { bool more_matches = false; bool match_found = false; size_t num_entries = (sizeof(Default_Bindings) / sizeof(binding_t)); - int len = strlen(Key_Buffer); + unsigned int len = strlen(Key_Buffer); /* If no more room then reset the buffer */ if (len+1 >= 16) { @@ -129,7 +129,7 @@ void input_handle_key(char ch) { /* If we got a valid key then process it */ if((char)ERR != ch) { - int i; + unsigned int i; /* Put the key in the buffer */ len++; Key_Buffer[len-1] = ch; @@ -142,14 +142,12 @@ void input_handle_key(char ch) { /* If the binding we're looking at matches a substring but has more chars * make note of it so we can wait for the next char */ - if((strlen(seq) > len) && (0 == strncmp(seq, Key_Buffer, len))) - { + if((strlen(seq) > len) && (0 == strncmp(seq, Key_Buffer, len))) { more_matches = true; } /* If the current string matches exactly then execute it's handler */ - if (0 == strcmp(Key_Buffer, seq)) - { + if (0 == strcmp(Key_Buffer, seq)) { binding.callback(); Key_Buffer[0] = '\0'; match_found = true; diff --git a/source/main.c b/source/main.c index 5cb8e80..18da209 100644 --- a/source/main.c +++ b/source/main.c @@ -11,16 +11,18 @@ #include "screen.h" void handle_signal(int sig) { + (void) sig; state_set_screen_dirty(true); state_set_screen_resized(true); } void handle_alarm(int sig) { + (void) sig; state_set_screen_dirty(true); alarm(1); } -int main(int argc, char** argv) { +int main() { /* Handle terminal resizing */ signal(SIGWINCH, handle_signal); signal(SIGALRM, handle_alarm); diff --git a/source/workdir.c b/source/workdir.c index 9531252..1c918bb 100644 --- a/source/workdir.c +++ b/source/workdir.c @@ -56,7 +56,7 @@ void workdir_set_idx(WorkDir_T* wd, int idx){ frame_set_highlighting(state_get_focused_frame(), false, false); wd->idx = idx; if(idx < 0) wd->idx = 0; - else if(idx >= vec_size(wd->vfiles)) + else if((unsigned int)idx >= vec_size(wd->vfiles)) wd->idx = vec_size(wd->vfiles)-1; frame_set_highlighting(state_get_focused_frame(), true, true); } @@ -157,7 +157,7 @@ void workdir_ls(WorkDir_T* wd){ } void workdir_seek(WorkDir_T* wd, char* search){ - int i = 0; + unsigned int i = 0; if(strcmp(((File_T*)vec_at(wd->vfiles, 0))->name, "..") == 0) i++; while(i < vec_size(wd->vfiles) && strcmp(((File_T*)vec_at(wd->vfiles, i))->name, search) < 0) i++; workdir_set_idx(wd, i); -- 2.54.0