diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index d6e4efc6..0684130c 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -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; } diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index a7a042cc..b97d1dba 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -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 ) ); diff --git a/source/dialogs/run.c b/source/dialogs/run.c index e06fbc67..9653dce4 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -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 = diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index ac87856d..b9ffcd2b 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -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 = diff --git a/source/rofi.c b/source/rofi.c index ef9bdf9d..f5b26aec 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -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; } }