summaryrefslogtreecommitdiff
path: root/src/skonfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/skonfig.c')
-rw-r--r--src/skonfig.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/skonfig.c b/src/skonfig.c
index a23f2d8..e244135 100644
--- a/src/skonfig.c
+++ b/src/skonfig.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <errno.h>
#if HAVE_STDBOOL_H
#include <stdbool.h>
@@ -187,10 +188,15 @@ void sk_init_config(struct sk_config *config, const char *config_file) {
#endif
fh = fopen(config_file, "r");
- sk_config_parse_file(config, fh);
- fclose(fh);
+ if (NULL == fh) {
+ sk_error("could not open config file (%s): %s",
+ config_file, strerror(errno));
+ } else {
+ sk_config_parse_file(config, fh);
+ fclose(fh);
+ }
- free((void *)config_file);
+ free((char *)config_file);
}
sk_config_parse_env(config);
@@ -235,6 +241,10 @@ int main(int argc, char *argv[]) {
/* Read in skonfig config */
struct sk_config *config = sk_config_alloc();
+ if (NULL == config) {
+ sk_error("could not allocate memory to store config data");
+ return EXIT_FAILURE;
+ }
sk_init_config(config, NULL);
/* update config from command line arguments */