I had to jump through an awkward hoop to get through the cast as result_key needs to be char **const for the subtraction to work. If it's char **const, I need to updated it at it's definition. What do you think of this incremental?
Ethan --- ovsdb/ovsdb-idlc.in | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ovsdb/ovsdb-idlc.in b/ovsdb/ovsdb-idlc.in index afac576..8df11df 100755 --- a/ovsdb/ovsdb-idlc.in +++ b/ovsdb/ovsdb-idlc.in @@ -26,10 +26,10 @@ def constify(cType, const): return cType def is_string_map(column): - return column.type.key \ - and column.type.value \ - and column.type.key.type == ovs.db.types.StringType \ - and column.type.value.type == ovs.db.types.StringType + return (column.type.key + and column.type.value + and column.type.key.type == ovs.db.types.StringType + and column.type.value.type == ovs.db.types.StringType) def cMembers(prefix, columnName, column, const): type = column.type @@ -531,15 +531,13 @@ 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) { - const char **keys = (const char **) row->key_%(c)s; - const char **values = (const char **) row->value_%(c)s; + char **const keys = row->key_%(c)s; + char **const values = row->value_%(c)s; size_t n_keys = row->n_%(c)s; - const char **result_key; - + char **const result_key = bsearch(&search_key, keys, n_keys, sizeof *keys, + bsearch_strcmp); assert(inited); - result_key = bsearch(&search_key, keys, n_keys, sizeof *keys, - bsearch_strcmp); - return result_key ? *(values + (result_key - keys)) : default_value; + return result_key ? values[result_key - keys] : default_value; }""" % {'s': structName, 'c': columnName} # Table columns. -- 1.7.9.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev