More const and signed correctness. Warnings now fit on one page!

This commit is contained in:
Peter Ammon 2012-01-14 22:48:53 -08:00
parent 9b133a978d
commit 60d1ac4fec
8 changed files with 20 additions and 25 deletions

View file

@ -390,7 +390,7 @@ static void daemonize()
/**
Get environment variable value. The resulting string needs to be free'd.
*/
static wchar_t *fishd_env_get( wchar_t *key )
static wchar_t *fishd_env_get( const wchar_t *key )
{
char *nres, *nkey;
wchar_t *res;

View file

@ -130,8 +130,6 @@ bool path_get_path_string(const wcstring &cmd_str, wcstring &output, const env_v
wchar_t *path_get_path( void *context, const wchar_t *cmd )
{
const wchar_t *path;
int err = ENOENT;
CHECK( cmd, 0 );

View file

@ -464,7 +464,7 @@ static void reader_kill( wchar_t *begin, int length, int mode, int newv )
free( old );
}
if( data->buff_pos > (begin-data->buff) )
if( data->buff_pos > (size_t)(begin-data->buff) )
{
data->buff_pos = maxi( begin-data->buff, data->buff_pos-length );
}
@ -1292,9 +1292,7 @@ static void reader_flash()
{
struct timespec pollint;
int i;
for( i=0; i<data->buff_pos; i++ )
for( size_t i=0; i<data->buff_pos; i++ )
{
data->color[i] = HIGHLIGHT_SEARCH_MATCH<<16;
}
@ -1976,7 +1974,7 @@ static void handle_token_history( int forward, int reset )
*/
static void move_word( int dir, int erase, int newv )
{
int end_buff_pos=data->buff_pos;
size_t end_buff_pos=data->buff_pos;
int step = dir?1:-1;
/*

View file

@ -109,7 +109,7 @@ static int next_tab_stop( int in )
static int calc_prompt_width( const wchar_t *prompt )
{
int res = 0;
int j, k;
size_t j, k;
for( j=0; prompt[j]; j++ )
{
@ -118,7 +118,7 @@ static int calc_prompt_width( const wchar_t *prompt )
/*
This is the start of an escape code. Try to guess it's width.
*/
int l;
size_t p;
int len=0;
int found = 0;
@ -164,14 +164,14 @@ static int calc_prompt_width( const wchar_t *prompt )
}
;
for( l=0; l < (sizeof(esc)/sizeof(char *)) && !found; l++ )
for( p=0; p < (sizeof(esc)/sizeof(char *)) && !found; p++ )
{
if( !esc[l] )
if( !esc[p] )
continue;
for( k=0; k<8; k++ )
{
len = try_sequence( tparm(esc[l],k), &prompt[j] );
len = try_sequence( tparm(esc[p],k), &prompt[j] );
if( len )
{
j += (len-1);
@ -181,17 +181,17 @@ static int calc_prompt_width( const wchar_t *prompt )
}
}
for( l=0; l < (sizeof(esc2)/sizeof(char *)) && !found; l++ )
for( p=0; p < (sizeof(esc2)/sizeof(char *)) && !found; p++ )
{
if( !esc2[l] )
if( !esc2[p] )
continue;
/*
Test both padded and unpadded version, just to
be safe. Most versions of tparm don't actually
seem to do anything these days.
*/
len = maxi( try_sequence( tparm(esc2[l]), &prompt[j] ),
try_sequence( esc2[l], &prompt[j] ));
len = maxi( try_sequence( tparm(esc2[p]), &prompt[j] ),
try_sequence( esc2[p], &prompt[j] ));
if( len )
{
@ -590,7 +590,7 @@ static void s_write_str( buffer_t *b, const wchar_t *s )
*/
static void s_update( screen_t *scr, const wchar_t *prompt )
{
int i, j, k;
size_t i, j;
int prompt_width = calc_prompt_width( prompt );
int current_width=0;
int screen_width = common_get_width();
@ -662,7 +662,7 @@ static void s_update( screen_t *scr, const wchar_t *prompt )
s_line.create_entry(current_width).text = o;
s_line.create_entry(current_width).color = o_c;
for( k=1; k<wcwidth(o); k++ )
for( int k=1; k<wcwidth(o); k++ )
s_line.create_entry(current_width+k).text = L'\0';
}

View file

@ -507,7 +507,7 @@ static int my_iswspace( wchar_t c )
const wchar_t *tok_get_desc( int type )
{
if( type < 0 || type >= sizeof( tok_desc ) )
if( type < 0 || (size_t)type >= sizeof( tok_desc ) )
{
return _(L"Invalid token type");
}

View file

@ -74,7 +74,7 @@ typedef struct
/** Type of last token*/
int last_type;
/** Length of last token*/
int last_len;
size_t last_len;
/** Offset of last token*/
int last_pos;
/** Whether there are more tokens*/

View file

@ -108,7 +108,6 @@ void hash_init2( hash_table_t *h,
int (*compare_func)(void *key1, void *key2),
size_t capacity)
{
int i;
size_t sz = 32;
while( sz < (capacity*4/3) )
sz*=2;
@ -127,7 +126,7 @@ void hash_init2( hash_table_t *h,
}
h->size = sz;
for( i=0; i< sz; i++ )
for( size_t i=0; i< sz; i++ )
h->arr[i].key = 0;
h->count=0;
h->hash_func = hash_func;

View file

@ -1087,10 +1087,10 @@ static int wildcard_expand_internal( const wchar_t *wc,
*/
if( whole_match )
{
wchar_t *new_wc = L"";
const wchar_t *new_wc = L"";
if( wc_end )
{
new_wc=const_cast<wchar_t*>(wc_end+1);
new_wc=wc_end+1;
/*
Accept multiple '/' as a single direcotry separator
*/