summaryrefslogtreecommitdiffstats
path: root/source/dialogs
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-03-19 13:29:04 +0100
committerDave Davenport <qball@gmpclient.org>2016-03-19 13:29:04 +0100
commita2869ef39d1e78c70877df27dc9a6ebc66962842 (patch)
tree98715f56cd4792a9c8b68a9933765a113fd37d41 /source/dialogs
parent1f8db0fc5a1da29346119937da5fe559469af2bc (diff)
Make clang static code analyzer happy (300+ -> 5)
Diffstat (limited to 'source/dialogs')
-rw-r--r--source/dialogs/combi.c5
-rw-r--r--source/dialogs/dmenu.c6
-rw-r--r--source/dialogs/run.c3
-rw-r--r--source/dialogs/script.c3
-rw-r--r--source/dialogs/ssh.c3
5 files changed, 13 insertions, 7 deletions
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index 1a266968..3dc1a773 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -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 ) );
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index 9add4934..89352bba 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -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.
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index f6c51ce7..fc8afa89 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -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 ) {
diff --git a/source/dialogs/script.c b/source/dialogs/script.c
index 99f7e41c..ef2c8d45 100644
--- a/source/dialogs/script.c
+++ b/source/dialogs/script.c
@@ -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 );
}
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index a2fe8b3f..28b66a3d 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -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;
}