diff --git a/builtin.cpp b/builtin.cpp index c4b36ed67..30a69b739 100644 --- a/builtin.cpp +++ b/builtin.cpp @@ -2218,8 +2218,7 @@ static int builtin_read( parser_t &parser, wchar_t **argv ) while( !finished ) { char b; - int read_res = read_blocked( builtin_stdin, &b, 1 ); - if( read_res <= 0 ) + if( read_blocked( builtin_stdin, &b, 1 ) <= 0 ) { eof=1; break; diff --git a/builtin_commandline.cpp b/builtin_commandline.cpp index ef5dbf924..3a0547d2f 100644 --- a/builtin_commandline.cpp +++ b/builtin_commandline.cpp @@ -61,8 +61,7 @@ static const wchar_t *current_buffer=0; What the commandline builtin considers to be the current cursor position. */ -static const size_t kInvalidCursorPosition = (size_t)(-1); -static size_t current_cursor_pos = kInvalidCursorPosition; +static size_t current_cursor_pos = (size_t)(-1); /** Returns the current commandline buffer. diff --git a/builtin_jobs.cpp b/builtin_jobs.cpp index a5653b5d6..1f01514cf 100644 --- a/builtin_jobs.cpp +++ b/builtin_jobs.cpp @@ -292,10 +292,10 @@ static int builtin_jobs( parser_t &parser, wchar_t **argv ) for( i=woptind; icount; i++ ) + for( int i=0; i < lst->count; i++ ) { e.param1.signal = lst->signal[i]; e.arguments->at(0) = sig2wcs( e.param1.signal ); diff --git a/exec.cpp b/exec.cpp index f222e671b..e20c48263 100644 --- a/exec.cpp +++ b/exec.cpp @@ -95,6 +95,8 @@ static void exec_write_and_exit( int fd, const char *buff, size_t count, int sta void exec_close( int fd ) { + ASSERT_IS_MAIN_THREAD(); + /* This may be called in a child of fork(), so don't allocate memory */ if( fd < 0 ) { @@ -113,7 +115,7 @@ void exec_close( int fd ) } /* Maybe remove this from our set of open fds */ - if (fd < (int)open_fds.size()) { + if (fd < open_fds.size()) { open_fds[fd] = false; } } @@ -134,7 +136,7 @@ int exec_pipe( int fd[2]) debug( 4, L"Created pipe using fds %d and %d", fd[0], fd[1]); int max_fd = std::max(fd[0], fd[1]); - if ((int)open_fds.size() <= max_fd) { + if (open_fds.size() <= max_fd) { open_fds.resize(max_fd + 1, false); } open_fds.at(fd[0]) = true; diff --git a/fish_pager.cpp b/fish_pager.cpp index 7c67d3481..3c9392b19 100644 --- a/fish_pager.cpp +++ b/fish_pager.cpp @@ -494,7 +494,7 @@ static void completion_print( int cols, int is_last = (j==(cols-1)); - if( (int)lst.size() <= j*rows + i ) + if( lst.size() <= j*rows + i ) continue; el = lst.at(j*rows + i ); @@ -872,11 +872,9 @@ static void mangle_descriptions( wcstring_list_t &lst ) */ static void join_completions( wcstring_list_t lst ) { - long i; - std::map desc_table; - for( i=0; i<(long)lst.size(); i++ ) + for( size_t i=0; i &color, size_t pos, // highlight the end of the subcommand assert(end >= subbuff); - if ((size_t)(end - subbuff) < length) { + if ((end - subbuff) < length) { color.at(end-subbuff)=HIGHLIGHT_OPERATOR; } @@ -1418,7 +1418,7 @@ static void highlight_universal_internal( const wcstring &buffstr, std::vectorparam1.pipe_fd[0], b, 4096 ); if( l==0 ) { diff --git a/mimedb.cpp b/mimedb.cpp index 9723f18cd..919e2033c 100644 --- a/mimedb.cpp +++ b/mimedb.cpp @@ -1033,13 +1033,13 @@ static void write_file( const char *file, int print_path ) \param files the list of files for which to perform the action \param fileno an internal value. Should always be set to zero. */ -static void launch( char *filter, const string_list_t &files, int fileno ) +static void launch( char *filter, const string_list_t &files, size_t fileno ) { char *filter_org=filter; int count=0; int launch_again=0; - if( (int)files.size() <= fileno ) + if( files.size() <= fileno ) return; diff --git a/output.cpp b/output.cpp index b557d19ae..b061693e4 100644 --- a/output.cpp +++ b/output.cpp @@ -161,7 +161,7 @@ static bool write_color(char *todo, unsigned char idx, bool is_fg) { } else { /* We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. */ char stridx[128]; - format_long_safe(stridx, (long)idx); + format_long_safe(stridx, idx); char buff[128] = "\x1b["; strcat(buff, is_fg ? "38;5;" : "48;5;"); strcat(buff, stridx); diff --git a/parse_util.cpp b/parse_util.cpp index e1599b333..b8cf04a00 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -132,7 +132,7 @@ size_t parse_util_get_offset( const wcstring &str, int line, long line_offset ) if( off2 == (size_t)(-1) ) { - off2 = (int)(wcslen( buff )+1); + off2 = wcslen( buff )+1; } if( line_offset2 < 0 ) diff --git a/proc.cpp b/proc.cpp index fc98365d8..7de06af53 100644 --- a/proc.cpp +++ b/proc.cpp @@ -377,8 +377,8 @@ static void mark_process_status( const job_t *j, char mess[MESS_SIZE]; snprintf( mess, MESS_SIZE, - "Process %d exited abnormally\n", - (int) p->pid ); + "Process %ld exited abnormally\n", + (long) p->pid ); /* If write fails, do nothing. We're in a signal handlers error handler. If things aren't working properly, it's safer to @@ -866,7 +866,7 @@ static void read_try( job_t *j ) while(1) { char b[BUFFER_SIZE]; - int l; + long l; l=read_blocked( buff->param1.pipe_fd[0], b, BUFFER_SIZE ); diff --git a/reader.cpp b/reader.cpp index 95c26c68a..8aabd5893 100644 --- a/reader.cpp +++ b/reader.cpp @@ -444,7 +444,9 @@ static void reader_repaint() parser_t::principal_parser().test( data->command_line.c_str(), &data->indents[0], 0, 0 ); wcstring full_line = (data->autosuggestion.empty() ? data->command_line : data->autosuggestion); - size_t len = std::max((size_t)1, full_line.size()); + size_t len = full_line.size(); + if (len < 1) + len = 1; std::vector colors = data->colors; colors.resize(len, HIGHLIGHT_AUTOSUGGESTION); diff --git a/sanity.cpp b/sanity.cpp index de2cd5db9..37e7e7e9f 100644 --- a/sanity.cpp +++ b/sanity.cpp @@ -60,7 +60,7 @@ void validate_pointer( const void *ptr, const wchar_t *err, int null_ok ) Test if the pointer data crosses a segment boundary. */ - if( (0x00000003l & (long)ptr) != 0 ) + if( (0x00000003l & (intptr_t)ptr) != 0 ) { debug( 0, _(L"The pointer '%ls' is invalid"), err ); sanity_lose(); diff --git a/signal.cpp b/signal.cpp index 708dd38a5..3b6bc2dbd 100644 --- a/signal.cpp +++ b/signal.cpp @@ -384,10 +384,10 @@ int wcs2sig( const wchar_t *str ) } } errno=0; - long res = wcstol( str, &end, 10 ); - if( !errno && res>=0 && res <= INT_MAX && !*end ) - return (int)res; - + int res = fish_wcstoi( str, &end, 10 ); + if( !errno && res>=0 && !*end ) + return res; + return -1; }