From: Justin Pettit Date: Mon, 9 Mar 2009 01:07:46 +0000 (-0700) Subject: Repair recently broken cfg_has_section(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9b253086f91f26c53954118f9907eb5d104ab8e;p=openvswitch Repair recently broken cfg_has_section(). --- diff --git a/lib/cfg.c b/lib/cfg.c index 6ad62021..00d355ef 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -47,7 +47,7 @@ /* XXX This file really needs a unit test! For a while, cfg_get_string(0, * "bridge.a.controller") would return the value of * "bridge.a.controller.in-band", if it existed, and I'm really not certain - * that the fix didn't break other things (e.g. cfg_has_section()). */ + * that the fix didn't break other things. */ /* List of configuration files. */ static struct svec cfg_files = SVEC_EMPTY_INITIALIZER; @@ -197,7 +197,7 @@ bool cfg_has_section(const char *section_, ...) { struct ds section; - bool retval; + bool retval = false; va_list args; char **p; @@ -207,8 +207,12 @@ cfg_has_section(const char *section_, ...) ds_put_char(§ion, '.'); va_end(args); - p = find_key_le(ds_cstr(§ion)); - retval = *p && !strncmp(section.string, *p, section.length); + for (p = cfg.names; *p; p++) { /* XXX this is inefficient */ + if (!strncmp(section.string, *p, section.length)) { + retval = true; + break; + } + } ds_destroy(§ion); return retval;