From: Steven Luo Date: Thu, 26 Aug 2010 11:49:20 +0000 (-0700) Subject: Simplify control flow in swb_config_load_option() X-Git-Tag: v3.3b2~24 X-Git-Url: http://git.maemo.org/git/?p=browser-switch;a=commitdiff_plain;h=113a6246253efb7a870c019d7ba2a7c852150937;hp=bbf5dd7221e8297a95a1b3d7b3937782ea7ca5d4 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. --- 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