Skip to content

Commit 2b3675c

Browse files
jfsmigfvennetier
authored andcommitted
gridinit: Fix compilation warnings
1 parent 6bac27c commit 2b3675c

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

main/gridinit.c

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,29 +1010,22 @@ _make_empty_env (void)
10101010
static GHashTable*
10111011
_cfg_extract_parameters (GKeyFile *kf, const char *s, const char *p, GError **err)
10121012
{
1013-
gchar **all_keys=NULL, **current_key=NULL;
10141013
gsize size=0;
1014+
gchar **all_keys = g_key_file_get_keys (kf, s, &size, err);
1015+
if (!all_keys)
1016+
return NULL;
10151017

10161018
GHashTable *ht = _make_empty_env ();
1017-
1018-
all_keys = g_key_file_get_keys (kf, s, &size, err);
1019-
if (!all_keys)
1020-
goto error;
1021-
for (current_key=all_keys; current_key && *current_key ;current_key++) {
1022-
if (g_str_has_prefix(*current_key, p)) {
1023-
gchar *value = g_key_file_get_value (kf, s, *current_key, err);
1024-
g_hash_table_insert (ht, g_strdup(*current_key + strlen(p)), value);
1019+
for (gchar **pk = all_keys; all_keys && *pk ;pk++) {
1020+
const char *key = *pk;
1021+
if (g_str_has_prefix(key, p)) {
1022+
gchar *value = g_key_file_get_value (kf, s, key, err);
1023+
g_hash_table_insert (ht, g_strdup(key + strlen(p)), value);
10251024
}
10261025
}
10271026

10281027
g_strfreev(all_keys);
10291028
return ht;
1030-
error:
1031-
if (ht)
1032-
g_hash_table_destroy(ht);
1033-
if (all_keys)
1034-
g_strfreev(all_keys);
1035-
return NULL;
10361029
}
10371030

10381031
static gchar*
@@ -1617,24 +1610,18 @@ _cfg_reload(gboolean services_only, GError **err)
16171610
WARN("reconfigure : glob error : %s", strerror(errno));
16181611
}
16191612
else {
1620-
char **p_str;
1621-
1622-
DEBUG("reconfigure : glob done, %"G_GSIZE_FORMAT" elements found", subfiles_glob.gl_pathc);
1623-
for (p_str=subfiles_glob.gl_pathv; p_str && *p_str ;p_str++) {
1613+
for (char **ps=subfiles_glob.gl_pathv; subfiles_glob.gl_pathv && *ps ;ps++) {
1614+
const char *path = *ps;
16241615
GError *gerr_local = NULL;
1625-
GKeyFile *sub_kf = NULL;
1626-
1627-
TRACE("Loading a new file");
1628-
1629-
sub_kf = g_key_file_new();
1630-
if (!g_key_file_load_from_file(sub_kf, *p_str, 0, &gerr_local))
1631-
WARN("Configuration file [%s] not parsed : %s", *p_str,
1616+
GKeyFile *sub_kf = g_key_file_new();
1617+
if (!g_key_file_load_from_file(sub_kf, path, 0, &gerr_local))
1618+
WARN("Configuration file [%s] not parsed : %s", path,
16321619
gerr_local ? gerr_local->message : "");
16331620
else if (!_cfg_reload_file(sub_kf, TRUE, &gerr_local))
1634-
WARN("Configuration file [%s] not loaded : %s", *p_str,
1621+
WARN("Configuration file [%s] not loaded : %s", path,
16351622
gerr_local ? gerr_local->message : "");
16361623
else
1637-
INFO("Loaded service file [%s]", *p_str);
1624+
INFO("Loaded service file [%s]", path);
16381625

16391626
if (gerr_local)
16401627
g_clear_error(&gerr_local);

0 commit comments

Comments
 (0)