From e84d614377dc3892da6969b846f53e999ce915ab Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 24 Jan 2008 10:47:01 +0100 Subject: [PATCH] replace some code using switch and warn() --- config.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index 6890e879..5f69f072 100644 --- a/config.c +++ b/config.c @@ -710,16 +710,22 @@ config_parse(const char *confpatharg) cfg = cfg_init(opts, CFGF_NONE); ret = cfg_parse(cfg, confpath); - if(ret == CFG_FILE_ERROR) + + switch(ret) { + case CFG_FILE_ERROR: perror("awesome: parsing configuration file failed"); if(!(defconfig = fopen(confpath, "w"))) perror("awesome: unable to create default configuration file"); - } - else if(ret == CFG_PARSE_ERROR) + break; + case CFG_PARSE_ERROR: cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath); - if(ret != CFG_SUCCESS) { - fprintf(stderr, "Using default compile-time configuration\n"); + break; + } + + if(ret != CFG_SUCCESS) + { + warn("using default compile-time configuration\n"); cfg_free(cfg); cfg = cfg_init(opts, CFGF_NONE); cfg_parse_buf(cfg, AWESOME_DEFAULT_CONFIG);