From 1ed4ac93ae35534397bc8267f255c380ef3193c4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 6 Apr 2012 00:55:59 +0200 Subject: Add some missing error handling --- src/config.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index f18d975..8c63b4e 100644 --- a/src/config.c +++ b/src/config.c @@ -163,7 +163,8 @@ void fastd_read_peer_dir(fastd_context *ctx, fastd_config *conf, const char *dir read_peer_dir(ctx, conf, conf->peer_dirs->str); - chdir(oldcwd); + if(chdir(oldcwd)) + pr_error(ctx, "can't chdir to `%s': %s", oldcwd, strerror(errno)); } else { pr_error(ctx, "change from directory `%s' to `%s' failed: %s", oldcwd, dir, strerror(errno)); @@ -250,7 +251,8 @@ bool fastd_read_config(fastd_context *ctx, fastd_config *conf, const char *filen fastd_config_pstate_delete(ps); fastd_config_yylex_destroy(scanner); - chdir(oldcwd); + if(chdir(oldcwd)) + pr_error(ctx, "can't chdir to `%s': %s", oldcwd, strerror(errno)); free(filename2); free(oldcwd); @@ -568,7 +570,9 @@ static void reconfigure_read_peer_dirs(fastd_context *ctx, fastd_config *new_con pr_error(ctx, "change from directory `%s' to `%s' failed: %s", oldcwd, dir->str, strerror(errno)); } - chdir(oldcwd); + if (chdir(oldcwd)) + pr_error(ctx, "can't chdir to `%s': %s", oldcwd, strerror(errno)); + free(oldcwd); } -- cgit v1.2.3