@@ -1010,29 +1010,22 @@ _make_empty_env (void)
1010
1010
static GHashTable *
1011
1011
_cfg_extract_parameters (GKeyFile * kf , const char * s , const char * p , GError * * err )
1012
1012
{
1013
- gchar * * all_keys = NULL , * * current_key = NULL ;
1014
1013
gsize size = 0 ;
1014
+ gchar * * all_keys = g_key_file_get_keys (kf , s , & size , err );
1015
+ if (!all_keys )
1016
+ return NULL ;
1015
1017
1016
1018
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 );
1025
1024
}
1026
1025
}
1027
1026
1028
1027
g_strfreev (all_keys );
1029
1028
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 ;
1036
1029
}
1037
1030
1038
1031
static gchar *
@@ -1617,24 +1610,18 @@ _cfg_reload(gboolean services_only, GError **err)
1617
1610
WARN ("reconfigure : glob error : %s" , strerror (errno ));
1618
1611
}
1619
1612
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 ;
1624
1615
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 ,
1632
1619
gerr_local ? gerr_local -> message : "" );
1633
1620
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 ,
1635
1622
gerr_local ? gerr_local -> message : "" );
1636
1623
else
1637
- INFO ("Loaded service file [%s]" , * p_str );
1624
+ INFO ("Loaded service file [%s]" , path );
1638
1625
1639
1626
if (gerr_local )
1640
1627
g_clear_error (& gerr_local );
0 commit comments