From 2768c0c160f2af5d04edf99da92b83fc087251fe Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Tue, 7 May 2019 18:33:55 +0200 Subject: libegg: reduce the scope of some variables Fixes 'cppcheck' warnings: [libegg/eggdesktopfile.c:483]: (style) The scope of the variable 'try_exec' can be reduced. [libegg/eggdesktopfile.c:483]: (style) The scope of the variable 'found_program' can be reduced. [libegg/eggdesktopfile.c:484]: (style) The scope of the variable 'only_show_in' can be reduced. [libegg/eggdesktopfile.c:484]: (style) The scope of the variable 'not_show_in' can be reduced. [libegg/eggdesktopfile.c:486]: (style) The scope of the variable 'i' can be reduced. [libegg/eggdesktopfile.c:608]: (style) The scope of the variable 'p' can be reduced. [libegg/eggsmclient-xsmp.c:227]: (style) The scope of the variable 'cmdline' can be reduced. [libegg/eggsmclient-xsmp.c:773]: (style) The scope of the variable 'fd' can be reduced. [libegg/eggsmclient-xsmp.c:808]: (style) The scope of the variable 'keys' can be reduced. [libegg/eggtreemultidnd.c:305]: (style) The scope of the variable 'context' can be reduced. --- libegg/eggsmclient-xsmp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libegg/eggsmclient-xsmp.c') diff --git a/libegg/eggsmclient-xsmp.c b/libegg/eggsmclient-xsmp.c index d93dcd1a..b95dc518 100644 --- a/libegg/eggsmclient-xsmp.c +++ b/libegg/eggsmclient-xsmp.c @@ -224,7 +224,7 @@ sm_client_xsmp_set_initial_properties (gpointer user_data) if (desktop_file) { GError *err = NULL; - char *cmdline, **argv; + char **argv; int argc; if (xsmp->restart_style == SmRestartIfRunning) @@ -236,6 +236,8 @@ sm_client_xsmp_set_initial_properties (gpointer user_data) if (!xsmp->set_restart_command) { + char *cmdline; + cmdline = egg_desktop_file_parse_exec (desktop_file, NULL, &err); if (cmdline && g_shell_parse_argv (cmdline, &argc, &argv, &err)) { @@ -770,7 +772,7 @@ save_state (EggSMClientXSMP *xsmp) char *state_file_path, *data; EggDesktopFile *desktop_file; GPtrArray *restart; - int offset, fd; + int offset; /* We set xsmp->state before emitting save_state, but our caller is * responsible for setting it back afterward. @@ -805,11 +807,13 @@ save_state (EggSMClientXSMP *xsmp) G_KEY_FILE_KEEP_TRANSLATIONS, NULL)) { guint g, k, i; - char **groups, **keys, *value, *exec; + char **groups, *value, *exec; groups = g_key_file_get_groups (state_file, NULL); for (g = 0; groups[g]; g++) { + char **keys; + keys = g_key_file_get_keys (state_file, groups[g], NULL, NULL); for (k = 0; keys[k]; k++) { @@ -861,6 +865,8 @@ save_state (EggSMClientXSMP *xsmp) offset = 0; while (1) { + int fd; + state_file_path = g_strdup_printf ("%s%csession-state%c%s-%ld.%s", g_get_user_config_dir (), G_DIR_SEPARATOR, G_DIR_SEPARATOR, -- cgit v1.2.1