From 113a6246253efb7a870c019d7ba2a7c852150937 Mon Sep 17 00:00:00 2001 From: Steven Luo Date: Thu, 26 Aug 2010 04:49:20 -0700 Subject: [PATCH] Simplify control flow in swb_config_load_option() Just return out of the loop when a match is found, and get rid of the retval variable. --- config.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/config.c b/config.c index 395bcf2..faa9816 100644 --- a/config.c +++ b/config.c @@ -101,8 +101,8 @@ static int swb_config_load_option(struct swb_config *cfg, char *name, char *value) { struct swb_config_option *opt; ptrdiff_t i; - int retval = 0; + /* Search through list of recognized config options for a match */ for (opt = swb_config_options; opt->name; ++opt) { if (strcmp(name, opt->name)) continue; @@ -124,14 +124,13 @@ static int swb_config_load_option(struct swb_config *cfg, We want the first value, so ignore this one */ free(value); } - retval = 1; + return 1; break; } - if (!retval) - free(value); - - return retval; + /* Unrecognized config option */ + free(value); + return 0; } /* Read the config file and load settings into the provided swb_config struct -- 1.7.9.5