From 2e1b3325c63cd6c43a10a08acfc54d1fb29a5c03 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 28 Jul 2012 17:49:46 -0700 Subject: [PATCH] Warning cleanup --- FishsFish.xcodeproj/project.pbxproj | 8 +++++++- autoload.cpp | 2 +- builtin_commandline.cpp | 14 +++++++------- builtin_jobs.cpp | 2 +- builtin_set.cpp | 4 ++-- common.cpp | 20 ++++++++++++-------- common.h | 6 +++--- complete.cpp | 5 +---- env.cpp | 5 ++--- fallback.cpp | 2 +- fallback.h | 2 +- fish.cpp | 4 ++-- fish_pager.cpp | 9 ++++----- highlight.cpp | 7 +++---- input_common.cpp | 6 +++--- parse_util.cpp | 12 ++++++------ parser.cpp | 2 +- proc.cpp | 2 +- reader.cpp | 12 ++++++------ screen.cpp | 15 +++++++-------- set_color.cpp | 29 ----------------------------- signal.cpp | 8 ++++---- tokenizer.cpp | 2 +- util.cpp | 21 ++++----------------- util.h | 12 ++++++++++-- wildcard.cpp | 9 ++++----- 26 files changed, 94 insertions(+), 126 deletions(-) diff --git a/FishsFish.xcodeproj/project.pbxproj b/FishsFish.xcodeproj/project.pbxproj index 94b953744..b9aad777d 100644 --- a/FishsFish.xcodeproj/project.pbxproj +++ b/FishsFish.xcodeproj/project.pbxproj @@ -779,7 +779,7 @@ D0A084F213B3AC130099B651 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0420; + LastUpgradeCheck = 0440; }; buildConfigurationList = D0A084F513B3AC130099B651 /* Build configuration list for PBXProject "FishsFish" */; compatibilityVersion = "Xcode 3.2"; @@ -1054,6 +1054,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEBUGGING_SYMBOLS = YES; GCC_DYNAMIC_NO_PIC = NO; @@ -1070,6 +1071,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_EXCEPTIONS = YES; @@ -1083,6 +1085,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; EXECUTABLE_NAME = fish_launcher; GCC_DYNAMIC_NO_PIC = NO; @@ -1102,6 +1105,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_NAME = fish_launcher; @@ -1248,6 +1252,7 @@ D0F019EE15A976F30034B3B1 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -1255,6 +1260,7 @@ D0F019EF15A976F30034B3B1 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + COMBINE_HIDPI_IMAGES = YES; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/autoload.cpp b/autoload.cpp index b1c48ca00..6ac3976fc 100644 --- a/autoload.cpp +++ b/autoload.cpp @@ -108,7 +108,7 @@ int autoload_t::load( const wcstring &cmd, bool reload ) res = this->locate_file_and_maybe_load_it( cmd, true, reload, path_list ); /* Clean up */ - int erased = is_loading_set.erase(cmd); + bool erased = !! is_loading_set.erase(cmd); assert(erased); return res; diff --git a/builtin_commandline.cpp b/builtin_commandline.cpp index c2bda9116..b8d3868af 100644 --- a/builtin_commandline.cpp +++ b/builtin_commandline.cpp @@ -94,7 +94,7 @@ static void replace_part( const wchar_t *begin, int append_mode ) { const wchar_t *buff = get_buffer(); - int out_pos=get_cursor_pos(); + long out_pos=get_cursor_pos(); wcstring out; @@ -118,7 +118,7 @@ static void replace_part( const wchar_t *begin, } case INSERT_MODE: { - int cursor = get_cursor_pos() -(begin-buff); + long cursor = get_cursor_pos() -(begin-buff); out.append( begin, cursor ); out.append( insert ); out.append( begin+cursor, end-begin-cursor ); @@ -127,7 +127,7 @@ static void replace_part( const wchar_t *begin, } } out.append( end ); - reader_set_buffer( out, out_pos ); + reader_set_buffer( out, (int)out_pos ); } /** @@ -222,12 +222,12 @@ static int builtin_commandline( parser_t &parser, wchar_t **argv ) current_buffer = (wchar_t *)builtin_complete_get_temporary_buffer(); if( current_buffer ) { - current_cursor_pos = wcslen( current_buffer ); + current_cursor_pos = (int)wcslen( current_buffer ); } else { current_buffer = reader_get_buffer(); - current_cursor_pos = reader_get_cursor_pos(); + current_cursor_pos = (int)reader_get_cursor_pos(); } if( !get_buffer() ) @@ -531,7 +531,7 @@ static int builtin_commandline( parser_t &parser, wchar_t **argv ) if( argc-woptind ) { wchar_t *endptr; - int new_pos; + long new_pos; errno = 0; new_pos = wcstol( argv[woptind], &endptr, 10 ); @@ -545,7 +545,7 @@ static int builtin_commandline( parser_t &parser, wchar_t **argv ) } current_buffer = reader_get_buffer(); - new_pos = maxi( 0, mini( new_pos, wcslen( current_buffer ) ) ); + new_pos = maxi( 0L, mini( (long)new_pos, (long)wcslen( current_buffer ) ) ); reader_set_buffer( current_buffer, new_pos ); return 0; } diff --git a/builtin_jobs.cpp b/builtin_jobs.cpp index e8dd8e762..a5653b5d6 100644 --- a/builtin_jobs.cpp +++ b/builtin_jobs.cpp @@ -305,7 +305,7 @@ static int builtin_jobs( parser_t &parser, wchar_t **argv ) return 1; } - j = job_get_from_pid( pid ); + j = job_get_from_pid( (int)pid ); if( j && !job_is_completed( j ) ) { diff --git a/builtin_set.cpp b/builtin_set.cpp index 57b477594..35dea7a12 100644 --- a/builtin_set.cpp +++ b/builtin_set.cpp @@ -174,7 +174,7 @@ static int my_env_set( const wchar_t *key, const wcstring_list_t &val, int scope static int parse_index( std::vector &indexes, const wchar_t *src, const wchar_t *name, - int var_count ) + size_t var_count ) { size_t len; @@ -715,7 +715,7 @@ static int builtin_set( parser_t &parser, wchar_t **argv ) /* Slice mode */ - int idx_count, val_count; + size_t idx_count, val_count; wcstring_list_t values; std::vector indexes; wcstring_list_t result; diff --git a/common.cpp b/common.cpp index 9986c8c11..b9a37729c 100644 --- a/common.cpp +++ b/common.cpp @@ -620,7 +620,7 @@ __sentinel bool contains_internal( const wcstring &needle, ... ) int read_blocked(int fd, void *buf, size_t count) { - int res; + ssize_t res; sigset_t chldset, oldset; sigemptyset( &chldset ); @@ -628,7 +628,7 @@ int read_blocked(int fd, void *buf, size_t count) VOMIT_ON_FAILURE(pthread_sigmask(SIG_BLOCK, &chldset, &oldset)); res = read( fd, buf, count ); VOMIT_ON_FAILURE(pthread_sigmask(SIG_SETMASK, &oldset, NULL)); - return res; + return (int)res; } ssize_t write_loop(int fd, const char *buff, size_t count) @@ -798,7 +798,7 @@ void format_long_safe(wchar_t buff[128], long val) { while (val > 0) { long rem = val % 10; /* Here we're assuming that wide character digits are contiguous - is that a correct assumption? */ - buff[idx++] = L'0' + (rem < 0 ? -rem : rem); + buff[idx++] = L'0' + (wchar_t)(rem < 0 ? -rem : rem); val /= 10; } if (negative) @@ -1114,8 +1114,10 @@ wcstring escape_string( const wcstring &in, escape_flags_t flags ) { wchar_t *unescape( const wchar_t * orig, int flags ) { - int mode = 0; - int in_pos, out_pos, len; + int mode = 0; + int out_pos; + size_t in_pos; + size_t len; int c; int bracket_count=0; wchar_t prev=0; @@ -1131,7 +1133,7 @@ wchar_t *unescape( const wchar_t * orig, int flags ) if( !in ) DIE_MEM(); - for( in_pos=0, out_pos=0; + for( in_pos=0, out_pos=0; in_pos=0)?in[out_pos]:0), out_pos++, in_pos++ ) { @@ -1220,6 +1222,8 @@ wchar_t *unescape( const wchar_t * orig, int flags ) { base=8; chars=3; + // note in_pod must be larger than 0 since we incremented it above + assert(in_pos > 0); in_pos--; break; } @@ -1227,7 +1231,7 @@ wchar_t *unescape( const wchar_t * orig, int flags ) for( i=0; i= 0) ) { diff --git a/fallback.cpp b/fallback.cpp index 50954ab08..473a046e8 100644 --- a/fallback.cpp +++ b/fallback.cpp @@ -915,7 +915,7 @@ int wcwidth( wchar_t c ) #endif #ifndef HAVE_WCSNDUP -wchar_t *wcsndup( const wchar_t *in, int c ) +wchar_t *wcsndup( const wchar_t *in, size_t c ) { wchar_t *res = (wchar_t *)malloc( sizeof(wchar_t)*(c+1) ); if( res == 0 ) diff --git a/fallback.h b/fallback.h index de8095644..2c091be01 100644 --- a/fallback.h +++ b/fallback.h @@ -290,7 +290,7 @@ int wcsncasecmp( const wchar_t *a, const wchar_t *b, int count ); Fallback for wcsndup function. Returns a copy of \c in, truncated to a maximum length of \c c. */ -wchar_t *wcsndup( const wchar_t *in, int c ); +wchar_t *wcsndup( const wchar_t *in, size_t c ); #endif diff --git a/fish.cpp b/fish.cpp index 3924f96ea..5e8c6b62d 100644 --- a/fish.cpp +++ b/fish.cpp @@ -319,14 +319,14 @@ static int fish_parse_opt( int argc, char **argv, const char **cmd_ptr ) case 'd': { char *end; - int tmp; + long tmp; errno = 0; tmp = strtol(optarg, &end, 10); if( tmp >= 0 && tmp <=10 && !*end && !errno ) { - debug_level=tmp; + debug_level = (int)tmp; } else { diff --git a/fish_pager.cpp b/fish_pager.cpp index 62b1a352b..d108d1161 100644 --- a/fish_pager.cpp +++ b/fish_pager.cpp @@ -483,8 +483,8 @@ static void completion_print( int cols, std::vector &lst ) { - int rows = (lst.size()-1)/cols+1; - int i, j; + size_t rows = (lst.size()-1)/cols+1; + size_t i, j; for( i = row_start; i (1< &colors, for( i=0; i= R_NULL) && (b < R_NULL + 1000) ) return b; @@ -228,11 +228,11 @@ wchar_t input_common_readch( int timed ) switch( sz ) { - case -1: + case (size_t)(-1): memset (&state, '\0', sizeof (state)); debug( 2, L"Illegal input" ); return R_NULL; - case -2: + case (size_t)(-2): break; case 0: return 0; diff --git a/parse_util.cpp b/parse_util.cpp index 47c99b1a1..181d9c99a 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -182,7 +182,7 @@ int parse_util_get_offset( const wcstring &str, int line, int line_offset ) if( off2 < 0 ) { - off2 = wcslen( buff )+1; + off2 = (int)(wcslen( buff )+1); } if( line_offset2 < 0 ) @@ -369,7 +369,7 @@ static void job_or_process_extent( const wchar_t *buff, int process ) { const wchar_t *begin, *end; - int pos; + long pos; wchar_t *buffcpy; int finished=0; @@ -484,7 +484,7 @@ void parse_util_token_extent( const wchar_t *buff, const wchar_t **prev_end ) { const wchar_t *begin, *end; - int pos; + long pos; wchar_t *buffcpy; tokenizer tok; @@ -714,9 +714,9 @@ wchar_t *parse_util_unescape_wildcards( const wchar_t *str ) token is not quoted. */ -static wchar_t get_quote( const wchar_t *cmd, int len ) +static wchar_t get_quote( const wchar_t *cmd, size_t len ) { - int i=0; + size_t i=0; wchar_t res=0; while( 1 ) @@ -780,7 +780,7 @@ void parse_util_get_parameter_info( const wcstring &cmd, const size_t pos, wchar wchar_t *cmd_tmp = wcsdup(cmd.c_str()); cmd_tmp[pos]=0; - int cmdlen = wcslen( cmd_tmp ); + size_t cmdlen = wcslen( cmd_tmp ); unfinished = (cmdlen==0); if( !unfinished ) { diff --git a/parser.cpp b/parser.cpp index 738bb985c..6d4e6f086 100644 --- a/parser.cpp +++ b/parser.cpp @@ -2350,7 +2350,7 @@ void parser_t::eval_job( tokenizer *tok ) { if( job_start_pos < tok_get_pos( tok ) ) { - int stop_pos = tok_get_pos( tok ); + long stop_pos = tok_get_pos( tok ); const wchar_t *newline = wcschr(tok_string(tok)+start_pos, L'\n'); if( newline ) stop_pos = mini( stop_pos, newline - tok_string(tok) ); diff --git a/proc.cpp b/proc.cpp index 5323de18d..fc98365d8 100644 --- a/proc.cpp +++ b/proc.cpp @@ -223,7 +223,7 @@ job_id_t acquire_job_id(void) { /* We found a slot. Note that slot 0 corresponds to job ID 1. */ *slot = true; - return slot - consumed_job_ids.begin() + 1; + return (job_id_t)(slot - consumed_job_ids.begin() + 1); } else { diff --git a/reader.cpp b/reader.cpp index 94ad22bf6..3bae07b59 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1953,7 +1953,7 @@ static void move_word( int dir, int erase, int newv ) /* Make sure we don't move beyond begining or end of buffer */ - end_buff_pos = maxi( 0, mini( end_buff_pos, data->command_length() ) ); + end_buff_pos = maxi( 0UL, mini( end_buff_pos, data->command_length() ) ); @@ -1997,7 +1997,7 @@ void reader_set_buffer( const wcstring &b, int p ) if( p>=0 ) { - data->buff_pos=mini( p, l ); + data->buff_pos=mini( (size_t)p, l ); } else { @@ -2724,7 +2724,7 @@ const wchar_t *reader_readline() const wchar_t *buff = data->command_line.c_str(); const wchar_t *begin = &buff[data->buff_pos]; const wchar_t *end = begin; - int len; + long len; while( *end && *end != L'\n' ) end++; @@ -2749,7 +2749,7 @@ const wchar_t *reader_readline() const wchar_t *buff = data->command_line.c_str(); const wchar_t *end = &buff[data->buff_pos]; const wchar_t *begin = end; - int len; + long len; while( begin > buff && *begin != L'\n' ) begin--; @@ -2757,7 +2757,7 @@ const wchar_t *reader_readline() if( *begin == L'\n' ) begin++; - len = maxi( end-begin, 1 ); + len = maxi( end-begin, 1L ); begin = end - len; reader_kill( begin - buff, len, KILL_PREPEND, last_char!=R_BACKWARD_KILL_LINE ); @@ -2780,7 +2780,7 @@ const wchar_t *reader_readline() if( *begin == L'\n' ) begin++; - len = maxi( end-begin, 0 ); + len = maxi( end-begin, 0L ); begin = end - len; while( *end && *end != L'\n' ) diff --git a/screen.cpp b/screen.cpp index 03bdd5b42..7087f14e4 100644 --- a/screen.cpp +++ b/screen.cpp @@ -460,7 +460,7 @@ static void s_desired_append_char( screen_t *s, { s->desired.line(line_no).append(ellipsis_char, HIGHLIGHT_COMMENT); - line_no = s->desired.line_count(); + line_no = (int)s->desired.line_count(); s->desired.add_line(); s->desired.cursor[1]++; s->desired.cursor[0]=0; @@ -653,7 +653,6 @@ static size_t line_shared_prefix(const line_t &a, const line_t &b) */ static void s_update( screen_t *scr, const wchar_t *prompt ) { - size_t i; int prompt_width = calc_prompt_width( prompt ); int screen_width = common_get_width(); int need_clear = scr->need_clear; @@ -677,7 +676,7 @@ static void s_update( screen_t *scr, const wchar_t *prompt ) scr->actual.cursor[0] = prompt_width; } - for (i=0; i < scr->desired.line_count(); i++) + for (size_t i=0; i < scr->desired.line_count(); i++) { const line_t &o_line = scr->desired.line(i); line_t &s_line = scr->actual.create_line(i); @@ -686,7 +685,7 @@ static void s_update( screen_t *scr, const wchar_t *prompt ) if( need_clear ) { - s_move( scr, &output, start_pos, i ); + s_move( scr, &output, start_pos, (int)i ); s_write_mbs( &output, clr_eol); s_line.clear(); } @@ -725,7 +724,7 @@ static void s_update( screen_t *scr, const wchar_t *prompt ) /* Now actually output stuff */ for ( ; j < o_line.size(); j++) { - s_move( scr, &output, current_width, i ); + s_move( scr, &output, current_width, (int)i ); s_set_color( scr, &output, o_line.color_at(j) ); s_write_char( scr, &output, o_line.char_at(j) ); current_width += fish_wcwidth(o_line.char_at(j)); @@ -735,15 +734,15 @@ static void s_update( screen_t *scr, const wchar_t *prompt ) int prev_length = (s_line.text.empty() ? 0 : fish_wcswidth(&s_line.text.at(0), s_line.text.size())); if (prev_length > current_width ) { - s_move( scr, &output, current_width, i ); + s_move( scr, &output, current_width, (int)i ); s_write_mbs( &output, clr_eol); } } /* Clear remaining lines */ - for( i=scr->desired.line_count(); i < scr->actual.line_count(); i++ ) + for( size_t i=scr->desired.line_count(); i < scr->actual.line_count(); i++ ) { - s_move( scr, &output, 0, i ); + s_move( scr, &output, 0, (int)i ); s_write_mbs( &output, clr_eol); } diff --git a/set_color.cpp b/set_color.cpp index 213d649c1..33f755c93 100644 --- a/set_color.cpp +++ b/set_color.cpp @@ -94,35 +94,6 @@ const int col_idx[]= 8 }; -int translate_color( char *str ) -{ - char *endptr; - int color; - - if( !str ) - return -1; - - errno = 0; - color = strtol( str, &endptr, 10 ); - - if( *endptr || color<0 || errno ) - { - size_t i; - color = -1; - for( i=0; i=0 && !*end ) - return res; + long res = wcstol( str, &end, 10 ); + if( !errno && res>=0 && res <= INT_MAX && !*end ) + return (int)res; return -1; } diff --git a/tokenizer.cpp b/tokenizer.cpp index acc2ce699..ae70f3162 100644 --- a/tokenizer.cpp +++ b/tokenizer.cpp @@ -232,7 +232,7 @@ static int myal( wchar_t c ) static void read_string( tokenizer *tok ) { const wchar_t *start; - int len; + long len; int mode=0; int do_loop=1; int paran_count=0; diff --git a/util.cpp b/util.cpp index ce36bd660..59ed9601d 100644 --- a/util.cpp +++ b/util.cpp @@ -47,19 +47,6 @@ */ #define SB_MAX_SIZE (128*1024*1024) -int mini( int a, - int b ) -{ - return ab?a:b; -} - int wcsfilecmp( const wchar_t *a, const wchar_t *b ) { CHECK( a, 0 ); @@ -76,13 +63,13 @@ int wcsfilecmp( const wchar_t *a, const wchar_t *b ) return 1; } - int secondary_diff=0; + long secondary_diff=0; if( iswdigit( *a ) && iswdigit( *b ) ) { wchar_t *aend, *bend; long al; long bl; - int diff; + long diff; errno = 0; al = wcstol( a, &aend, 10 ); @@ -98,7 +85,7 @@ int wcsfilecmp( const wchar_t *a, const wchar_t *b ) diff = al - bl; if( diff ) - return diff>0?2:-2; + return diff > 0 ? 2 : -2; secondary_diff = (aend-a) - (bend-b); @@ -124,7 +111,7 @@ int wcsfilecmp( const wchar_t *a, const wchar_t *b ) */ if( secondary_diff ) { - return secondary_diff>0?1:-1; + return secondary_diff > 0 ? 1 :-1; } } diff --git a/util.h b/util.h index 4354d52dd..b3893cb12 100644 --- a/util.h +++ b/util.h @@ -29,12 +29,20 @@ buffer_t; /** Returns the larger of two ints */ -int maxi( int a, int b ); +template +static inline T maxi( T a, T b ) +{ + return a>b?a:b; +} /** Returns the smaller of two ints */ -int mini( int a, int b ); +template +static inline T mini( T a, T b ) +{ + return a