[ovs-dev] [PATCH 2/2] idl: New helpers for accessing string maps.
Ben Pfaff
blp at nicira.com
Thu Mar 22 18:38:50 UTC 2012
On Thu, Mar 22, 2012 at 11:32:06AM -0700, Ethan Jackson wrote:
> Sure here it is. (Rebased against master).
Thanks a lot.
If I fold in the following (basically dropping all the "const"s) it
compiles warning-free for me and the generated code is prettier. What
do you think?
Thanks,
Ben.
diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in
index 8df11df..5931837 100755
--- a/ovsdb/ovsdb-idlc.in
+++ b/ovsdb/ovsdb-idlc.in
@@ -531,12 +531,14 @@ const struct ovsdb_datum *
print """
const char * %(s)s_get_%(c)s_value(const struct %(s)s *row, const char *search_key, const char *default_value)
{
- char **const keys = row->key_%(c)s;
- char **const values = row->value_%(c)s;
+ char **keys = row->key_%(c)s;
+ char **values = row->value_%(c)s;
size_t n_keys = row->n_%(c)s;
- char **const result_key = bsearch(&search_key, keys, n_keys, sizeof *keys,
- bsearch_strcmp);
+ char **result_key;
+
assert(inited);
+ result_key = bsearch(&search_key, keys, n_keys, sizeof *keys,
+ bsearch_strcmp);
return result_key ? values[result_key - keys] : default_value;
}""" % {'s': structName, 'c': columnName}
More information about the dev
mailing list