summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsk1080 <slasherking823@gmail.com>2012-09-23 15:28:35 -0800
committerLars-Dominik Braun <lars@6xq.net>2012-09-24 12:21:30 +0200
commit5fd56271bfb4a407fffcd8633b54501e42415ead (patch)
treefbf4fe34d4e5495a5b78236afa14e143c7077d40 /src
parent1c1628706034eac85b062a028bacc85bc18efc22 (diff)
downloadpianobar-5fd56271bfb4a407fffcd8633b54501e42415ead.tar.gz
pianobar-5fd56271bfb4a407fffcd8633b54501e42415ead.tar.bz2
pianobar-5fd56271bfb4a407fffcd8633b54501e42415ead.zip
Fix fclose outside of file loop
Closes #307.
Diffstat (limited to 'src')
-rw-r--r--src/settings.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/settings.c b/src/settings.c
index 670bcc0..c8bcbfe 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -113,10 +113,7 @@ void BarSettingsDestroy (BarSettings_t *settings) {
* @return nothing yet
*/
void BarSettingsRead (BarSettings_t *settings) {
- char *configfiles[] = {PACKAGE "/state", PACKAGE "/config"},
- path[PATH_MAX], key[256], val[256];
- FILE *configfd;
- static const char *formatMsgPrefix = "format_msg_";
+ char *configfiles[] = {PACKAGE "/state", PACKAGE "/config"};
assert (sizeof (settings->keys) / sizeof (*settings->keys) ==
sizeof (dispatchActions) / sizeof (*dispatchActions));
@@ -166,6 +163,10 @@ void BarSettingsRead (BarSettings_t *settings) {
/* read config files */
for (size_t j = 0; j < sizeof (configfiles) / sizeof (*configfiles); j++) {
+ static const char *formatMsgPrefix = "format_msg_";
+ char key[256], val[256], path[PATH_MAX];
+ FILE *configfd;
+
BarGetXdgConfigDir (configfiles[j], path, sizeof (path));
if ((configfd = fopen (path, "r")) == NULL) {
continue;
@@ -316,6 +317,8 @@ void BarSettingsRead (BarSettings_t *settings) {
}
}
}
+
+ fclose (configfd);
}
/* check environment variable if proxy is not set explicitly */
@@ -325,8 +328,6 @@ void BarSettingsRead (BarSettings_t *settings) {
settings->proxy = strdup (tmpProxy);
}
}
-
- fclose (configfd);
}
/* write statefile