1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Fix compile warnings with CLANG.

* signed compare with unsigned.
This commit is contained in:
Dave Davenport 2014-08-22 17:29:15 +02:00
parent 86b7571e04
commit b665e85e69
2 changed files with 14 additions and 4 deletions

View file

@ -37,7 +37,7 @@
char *dmenu_prompt = "dmenu ";
static char **get_dmenu ( unsigned int *length )
static char **get_dmenu ( int *length )
{
char buffer[1024];
char **retv = NULL;
@ -55,6 +55,10 @@ static char **get_dmenu ( unsigned int *length )
}
( *length )++;
// Stop when we hit 2³¹ entries.
if( (*length) == INT_MAX) {
return retv;
}
}
return retv;
@ -64,7 +68,7 @@ int dmenu_switcher_dialog ( char **input )
{
int selected_line = 0;
int retv = FALSE;
unsigned int length = 0;
int length = 0;
char **list = get_dmenu ( &length );
int restart = FALSE;

View file

@ -1141,7 +1141,9 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
int last_offset = 0;
int init = 0;
if ( selected_line != NULL ) {
if ( *selected_line >= 0 && *selected_line <= num_lines ) {
// The cast to unsigned in here is valid, we checked if selected_line > 0.
// So its maximum range is 0-2³¹, well within the num_lines range.
if ( *selected_line >= 0 && (unsigned int)(*selected_line) <= num_lines ) {
selected = *selected_line;
}
}
@ -1164,7 +1166,11 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
}
// Try to look-up the selected line and highlight that.
// This is needed 'hack' to fix the dmenu 'next row' modi.
if ( init == 0 && selected_line != NULL && ( *selected_line ) == i ) {
// int to unsigned int is valid because we check negativeness of
// selected_line
if ( init == 0 && selected_line != NULL &&
(*selected_line) >= 0 &&
((unsigned int)( *selected_line )) == i ) {
selected = j;
init = 1;
}