mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
json: Always use the json_string() method to access the strings.
We'll be changing the way strings are stored, so the direct access will not be safe anymore. Change all the users to use the proper API as they should have been doing anyway. This also means splitting the handling of strings and serialized objects in most cases as they will be treated differently. The only code outside of json implementation for which direct access is preserved is substitute_uuids() in test-ovsdb.c. It's an unusual string manipulation that is only needed for the testing, so doesn't seem worthy adding a new API function. We could introduce something like json_string_replace() if this use case will appear somewhere else in the future. Acked-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
@@ -247,15 +247,17 @@ record_id_equals(const union ovsdb_atom *name, enum ovsdb_atomic_type type,
|
||||
const char *record_id)
|
||||
{
|
||||
if (type == OVSDB_TYPE_STRING) {
|
||||
if (!strcmp(name->s->string, record_id)) {
|
||||
const char *name_str = json_string(name->s);
|
||||
|
||||
if (!strcmp(name_str, record_id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
struct uuid uuid;
|
||||
size_t len = strlen(record_id);
|
||||
if (len >= 4
|
||||
&& uuid_from_string(&uuid, name->s->string)
|
||||
&& !strncmp(name->s->string, record_id, len)) {
|
||||
&& uuid_from_string(&uuid, name_str)
|
||||
&& !strncmp(name_str, record_id, len)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user