2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 01:51:26 +00:00

tests: Fix multiple Coverity warnings in test programs.

This patch addresses several common issues in various test programs
instead of sending multiple small patches.  While these are not
critical, cleaning them up improves code quality.

- Fixed two resource leaks in test-aa.c and test-ovsdb.c.
- Fixed four instances of unchecked return values in test-ovsdb.c
  and test-packet.c.
- Fixed one out-of-bounds read in test-ccmap.c

Acked-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
This commit is contained in:
Eelco Chaudron 2025-02-06 12:09:39 +01:00
parent de39a55877
commit 68245b0c4a
4 changed files with 10 additions and 5 deletions

View File

@ -239,6 +239,7 @@ test_aa_send(void)
if (n == 0) {
printf("Error: unable to build packet\n");
lldp_destroy_dummy(lldp);
return 1;
}

View File

@ -129,7 +129,7 @@ test_ccmap_inc_dec(hash_func *hash)
check_ccmap(&ccmap, values, i + 1, hash);
}
shuffle(values, N_ELEMS);
for (i = 0; i < N_ELEMS; i++) {
for (i = 0; i < (N_ELEMS - 1); i++) {
ccmap_dec(&ccmap, hash(values[i]));
check_ccmap(&ccmap, values + (i + 1), N_ELEMS - (i + 1), hash);
}

View File

@ -426,6 +426,7 @@ do_log_io(struct ovs_cmdl_context *ctx)
}
ovsdb_log_close(log);
ovsdb_log_close(replacement);
}
static void
@ -3089,7 +3090,8 @@ do_idl_partial_update_set_column(struct ovs_cmdl_context *ctx)
myTxn = ovsdb_idl_txn_create(idl);
idltest_simple3_get_uset(myRow, OVSDB_TYPE_UUID);
struct uuid uuid_to_add;
uuid_from_string(&uuid_to_add, "001e43d2-dd3f-4616-ab6a-83a490bb0991");
ovs_assert(uuid_from_string(&uuid_to_add,
"001e43d2-dd3f-4616-ab6a-83a490bb0991"));
idltest_simple3_update_uset_addvalue(myRow, uuid_to_add);
idltest_simple3_set_name(myRow, "String2");
ovsdb_idl_txn_commit_block(myTxn);
@ -3101,7 +3103,8 @@ do_idl_partial_update_set_column(struct ovs_cmdl_context *ctx)
/* Insert duplicate element. */
myTxn = ovsdb_idl_txn_create(idl);
struct uuid uuid_to_add2;
uuid_from_string(&uuid_to_add2, "0026b3ba-571b-4729-8227-d860a5210ab8");
ovs_assert(uuid_from_string(&uuid_to_add2,
"0026b3ba-571b-4729-8227-d860a5210ab8"));
idltest_simple3_update_uset_addvalue(myRow, uuid_to_add2);
ovsdb_idl_txn_commit_block(myTxn);
ovsdb_idl_txn_destroy(myTxn);
@ -3145,7 +3148,8 @@ do_idl_partial_update_set_column(struct ovs_cmdl_context *ctx)
/* create row, insert key, delete row */
myTxn = ovsdb_idl_txn_create(idl);
myRow = idltest_simple3_insert(myTxn);
uuid_from_string(&uuid_to_add, "12345678-dd3f-4616-ab6a-83a490bb0991");
ovs_assert(uuid_from_string(&uuid_to_add,
"12345678-dd3f-4616-ab6a-83a490bb0991"));
idltest_simple3_update_uset_addvalue(myRow, uuid_to_add);
idltest_simple3_set_name(myRow, "String2");
idltest_simple3_delete(myRow);

View File

@ -157,7 +157,7 @@ test_ipv6_parsing(void)
struct in6_addr o_ipv6, p_ipv6;
struct in6_addr mask;
inet_pton(AF_INET6, "2001:db8:0:0:0:0:2:1", &o_ipv6);
assert(inet_pton(AF_INET6, "2001:db8:0:0:0:0:2:1", &o_ipv6) == 1);
assert(!ipv6_parse_masked("2001:db8:0:0:0:0:2:1/64", &p_ipv6, &mask));
assert(ipv6_addr_equals(&o_ipv6, &p_ipv6));