1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Fix some compiler warnings

This commit is contained in:
Dave Davenport 2015-10-19 09:23:06 +02:00
parent 1b425c7bd0
commit 64cb4c781c
5 changed files with 28 additions and 13 deletions

View file

@ -169,11 +169,11 @@ static SwitcherMode combi_mode_result ( int mretv, char **input, unsigned int se
if ( switcher >= 0 ) {
char *n = strchr ( *input, ' ' );
// skip whitespace
if( n != NULL) {
if ( n != NULL ) {
n++;
return pd->switchers[switcher]->result ( mretv, &n,
selected_line - pd->starts[switcher],
pd->switchers[switcher] );
selected_line - pd->starts[switcher],
pd->switchers[switcher] );
}
return MODE_EXIT;
}

View file

@ -124,6 +124,9 @@ static void parse_pair ( char *input, struct range_pair *item )
static void parse_ranges ( char *input, struct range_pair **list, unsigned int *length )
{
char *endp;
if ( input == NULL ) {
return;
}
for ( char *token = strtok_r ( input, ",", &endp ); token != NULL; token = strtok_r ( NULL, ",", &endp ) ) {
// Make space.
*list = g_realloc ( ( *list ), ( ( *length ) + 1 ) * sizeof ( struct range_pair ) );

View file

@ -282,7 +282,7 @@ static char ** run_mode_get_data ( unsigned int *length, Switcher *sw )
rmpd->cmd_list_length = 0;
rmpd->cmd_list = get_apps ( &( rmpd->cmd_list_length ) );
}
if(length != NULL) {
if ( length != NULL ) {
*length = rmpd->cmd_list_length;
}
return rmpd->cmd_list;
@ -335,7 +335,7 @@ static void run_mode_destroy ( Switcher *sw )
static const char *mgrv ( unsigned int selected_line, void *sw, G_GNUC_UNUSED int *state )
{
return run_mode_get_data(NULL, sw)[selected_line];
return run_mode_get_data ( NULL, sw )[selected_line];
}
Switcher run_mode =

View file

@ -335,7 +335,7 @@ static char ** ssh_mode_get_data ( unsigned int *length, Switcher *sw )
rmpd->cmd_list_length = 0;
rmpd->cmd_list = get_ssh ( &( rmpd->cmd_list_length ) );
}
if( length != NULL ) {
if ( length != NULL ) {
*length = rmpd->cmd_list_length;
}
return rmpd->cmd_list;
@ -383,7 +383,7 @@ static void ssh_mode_destroy ( Switcher *sw )
static const char *mgrv ( unsigned int selected_line, void *sw, G_GNUC_UNUSED int *state )
{
return ssh_mode_get_data(NULL, sw)[selected_line];
return ssh_mode_get_data ( NULL, sw )[selected_line];
}
Switcher ssh_mode =

View file

@ -1877,13 +1877,22 @@ static gpointer rofi_signal_handler_process ( gpointer arg )
else {
// Send message to main thread.
if ( sig == SIGHUP ) {
write ( pfd, "c", 1 );
ssize_t t = write ( pfd, "c", 1 );
if ( t < 0 ) {
fprintf ( stderr, "Failed to send signal to main thread.\n" );
}
}
if ( sig == SIGUSR1 ) {
write ( pfd, "i", 1 );
ssize_t t = write ( pfd, "i", 1 );
if ( t < 0 ) {
fprintf ( stderr, "Failed to send signal to main thread.\n" );
}
}
else if ( sig == SIGINT ) {
write ( pfd, "q", 1 );
ssize_t t = write ( pfd, "q", 1 );
if ( t < 0 ) {
fprintf ( stderr, "Failed to send signal to main thread.\n" );
}
// Close my end and exit.
g_thread_exit ( NULL );
}
@ -2190,10 +2199,13 @@ int main ( int argc, char *argv[] )
// Signal Pipe
if ( FD_ISSET ( pfds[0], &in_fds ) ) {
// The signal thread send us a message. Process it.
char c;
read ( pfds[0], &c, 1 );
char c;
ssize_t r = read ( pfds[0], &c, 1 );
if ( r < 0 ) {
fprintf ( stderr, "Failed to read data from signal thread: %s\n", strerror ( errno ) );
}
// Process the signal in the main_loop.
if ( main_loop_signal_handler ( c, quiet ) ) {
else if ( main_loop_signal_handler ( c, quiet ) ) {
break;
}
}