mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Make clang static code analyzer happy (300+ -> 5)
This commit is contained in:
parent
1f8db0fc5a
commit
a2869ef39d
11 changed files with 31 additions and 16 deletions
|
@ -53,9 +53,10 @@ static void combi_mode_parse_switchers ( Mode *sw )
|
|||
char *savept = NULL;
|
||||
// Make a copy, as strtok will modify it.
|
||||
char *switcher_str = g_strdup ( config.combi_modi );
|
||||
const char * const sep = ",";
|
||||
// Split token on ','. This modifies switcher_str.
|
||||
for ( char *token = strtok_r ( switcher_str, ",", &savept ); token != NULL;
|
||||
token = strtok_r ( NULL, ",", &savept ) ) {
|
||||
for ( char *token = strtok_r ( switcher_str, sep, &savept ); token != NULL;
|
||||
token = strtok_r ( NULL, sep, &savept ) ) {
|
||||
// Resize and add entry.
|
||||
pd->switchers = (Mode * *) g_realloc ( pd->switchers,
|
||||
sizeof ( Mode* ) * ( pd->num_switchers + 1 ) );
|
||||
|
|
|
@ -123,7 +123,8 @@ static unsigned int dmenu_mode_get_num_entries ( const Mode *sw )
|
|||
static void parse_pair ( char *input, struct range_pair *item )
|
||||
{
|
||||
int index = 0;
|
||||
for ( char *token = strsep ( &input, "-" ); token != NULL; token = strsep ( &input, "-" ) ) {
|
||||
const char * const sep = "-";
|
||||
for ( char *token = strsep ( &input, sep ); token != NULL; token = strsep ( &input, sep ) ) {
|
||||
if ( index == 0 ) {
|
||||
item->start = item->stop = (unsigned int) strtoul ( token, NULL, 10 );
|
||||
index++;
|
||||
|
@ -145,7 +146,8 @@ static void parse_ranges ( char *input, struct range_pair **list, unsigned int *
|
|||
if ( input == NULL ) {
|
||||
return;
|
||||
}
|
||||
for ( char *token = strtok_r ( input, ",", &endp ); token != NULL; token = strtok_r ( NULL, ",", &endp ) ) {
|
||||
const char *const sep =",";
|
||||
for ( char *token = strtok_r ( input, sep, &endp ); token != NULL; token = strtok_r ( NULL, sep, &endp ) ) {
|
||||
// Make space.
|
||||
*list = g_realloc ( ( *list ), ( ( *length ) + 1 ) * sizeof ( struct range_pair ) );
|
||||
// Parse a single pair.
|
||||
|
|
|
@ -249,7 +249,8 @@ static char ** get_apps ( unsigned int *length )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
for ( const char *dirname = strtok ( path, ":" ); dirname != NULL; dirname = strtok ( NULL, ":" ) ) {
|
||||
const char *const sep = ":";
|
||||
for ( const char *dirname = strtok ( path, sep ); dirname != NULL; dirname = strtok ( NULL, sep ) ) {
|
||||
DIR *dir = opendir ( dirname );
|
||||
|
||||
if ( dir != NULL ) {
|
||||
|
|
|
@ -183,7 +183,8 @@ Mode *script_switcher_parse_setup ( const char *str )
|
|||
char *endp = NULL;
|
||||
char *parse = g_strdup ( str );
|
||||
unsigned int index = 0;
|
||||
for ( char *token = strtok_r ( parse, ":", &endp ); token != NULL; token = strtok_r ( NULL, ":", &endp ) ) {
|
||||
const char *const sep = ":";
|
||||
for ( char *token = strtok_r ( parse, sep, &endp ); token != NULL; token = strtok_r ( NULL, sep, &endp ) ) {
|
||||
if ( index == 0 ) {
|
||||
g_strlcpy ( sw->name, token, 32 );
|
||||
}
|
||||
|
|
|
@ -303,7 +303,8 @@ static char ** get_ssh ( unsigned int *length )
|
|||
// (how many host names contain spaces?).
|
||||
while ( ( token = strtok ( NULL, SSH_TOKEN_DELIM ) ) ) {
|
||||
// We do not want to show wildcard entries, as you cannot ssh to them.
|
||||
if ( *token == '!' || strpbrk ( token, "*?" ) ) {
|
||||
const char *const sep = "*?";
|
||||
if ( *token == '!' || strpbrk ( token, sep ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,8 @@ char **tokenize ( const char *input, int case_sensitive )
|
|||
|
||||
// Iterate over tokens.
|
||||
// strtok should still be valid for utf8.
|
||||
for ( token = strtok_r ( str, " ", &saveptr ); token != NULL; token = strtok_r ( NULL, " ", &saveptr ) ) {
|
||||
const char * const sep = " ";
|
||||
for ( token = strtok_r ( str, sep, &saveptr ); token != NULL; token = strtok_r ( NULL, sep, &saveptr ) ) {
|
||||
retv = g_realloc ( retv, sizeof ( char* ) * ( num_tokens + 2 ) );
|
||||
if ( config.glob ) {
|
||||
char *str = g_strdup_printf ( "*%s*", token );
|
||||
|
|
|
@ -111,7 +111,8 @@ gboolean parse_keys_abe ( void )
|
|||
abe[iter].num_bindings = 0;
|
||||
|
||||
// Iter over bindings.
|
||||
for ( char *entry = strtok_r ( keystr, ",", &sp ); entry != NULL; entry = strtok_r ( NULL, ",", &sp ) ) {
|
||||
const char *const sep = ",";
|
||||
for ( char *entry = strtok_r ( keystr, sep, &sp ); entry != NULL; entry = strtok_r ( NULL, sep, &sp ) ) {
|
||||
abe[iter].kb = g_realloc ( abe[iter].kb, ( abe[iter].num_bindings + 1 ) * sizeof ( KeyBinding ) );
|
||||
KeyBinding *kb = &( abe[iter].kb[abe[iter].num_bindings] );
|
||||
if ( !x11_parse_key ( entry, &( kb->modmask ), &( kb->keysym ) ) ) {
|
||||
|
|
|
@ -403,11 +403,12 @@ static int add_mode ( const char * token )
|
|||
}
|
||||
static void setup_modi ( void )
|
||||
{
|
||||
const char *const sep =",";
|
||||
char *savept = NULL;
|
||||
// Make a copy, as strtok will modify it.
|
||||
char *switcher_str = g_strdup ( config.modi );
|
||||
// Split token on ','. This modifies switcher_str.
|
||||
for ( char *token = strtok_r ( switcher_str, ",", &savept ); token != NULL; token = strtok_r ( NULL, ",", &savept ) ) {
|
||||
for ( char *token = strtok_r ( switcher_str, sep, &savept ); token != NULL; token = strtok_r ( NULL, sep, &savept ) ) {
|
||||
add_mode ( token );
|
||||
}
|
||||
// Free string that was modified by strtok_r
|
||||
|
|
|
@ -622,7 +622,8 @@ static void textbox_parse_string ( const char *str, RowColor *color )
|
|||
char *endp = NULL;
|
||||
char *token;
|
||||
int index = 0;
|
||||
for ( token = strtok_r ( cstr, ",", &endp ); token != NULL; token = strtok_r ( NULL, ",", &endp ) ) {
|
||||
const char *const sep = ",";
|
||||
for ( token = strtok_r ( cstr, sep, &endp ); token != NULL; token = strtok_r ( NULL, sep, &endp ) ) {
|
||||
switch ( index )
|
||||
{
|
||||
case 0:
|
||||
|
|
|
@ -62,6 +62,9 @@
|
|||
|
||||
#include "xcb.h"
|
||||
|
||||
const char *const separator_style_none = "none";
|
||||
const char *const separator_style_dash = "dash";
|
||||
|
||||
GThreadPool *tpool = NULL;
|
||||
|
||||
RofiViewState *current_active_menu = NULL;
|
||||
|
@ -931,8 +934,8 @@ void rofi_view_update ( RofiViewState *state )
|
|||
}
|
||||
color_separator ( d );
|
||||
|
||||
if ( strcmp ( config.separator_style, "none" ) ) {
|
||||
if ( strcmp ( config.separator_style, "dash" ) == 0 ) {
|
||||
if ( strcmp ( config.separator_style, separator_style_none ) ) {
|
||||
if ( strcmp ( config.separator_style, separator_style_dash ) == 0 ) {
|
||||
const double dashes[1] = { 4 };
|
||||
cairo_set_dash ( d, dashes, 1, 0.0 );
|
||||
}
|
||||
|
|
|
@ -523,13 +523,15 @@ void config_parse_xresources_theme_dump ( void )
|
|||
printf ( "! ROFI Color theme\n" );
|
||||
printf ( "! User: %s\n", g_get_user_name () );
|
||||
printf ( "! ------------------------------------------------------------------------------\n" );
|
||||
const char * namePrefix = "rofi";
|
||||
const char * const namePrefix = "rofi";
|
||||
const char colorPrefix[] = "color-";
|
||||
const char separatorStyle[] = "separator-style";
|
||||
unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions );
|
||||
for ( unsigned int i = 0; i < entries; ++i ) {
|
||||
if ( strncmp ( xrmOptions[i].name, "color-", 6 ) == 0 ) {
|
||||
if ( strncmp ( xrmOptions[i].name, colorPrefix, sizeof(colorPrefix)-1 ) == 0 ) {
|
||||
xresource_dump_entry ( namePrefix, &xrmOptions[i] );
|
||||
}
|
||||
else if ( strcmp ( xrmOptions[i].name, "separator-style" ) == 0 ) {
|
||||
else if ( strcmp ( xrmOptions[i].name, separatorStyle ) == 0 ) {
|
||||
xresource_dump_entry ( namePrefix, &xrmOptions[i] );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue