In jsonrpc_session_recv() use nullable_string_is_equal() instead of
strcmp() in cases where we haven't already checked that the pointer
isn't NULL.
Found with clang analyze.
Fixes: 4931f33ad9e2 ("ovsdb-server: Factor out complication by using
jsonrpc_session.")
Signed-off-by: Mike Pattrick <[email protected]>
---
lib/jsonrpc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c
index f01a2e56f..4a6748a45 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -1196,7 +1196,8 @@ jsonrpc_session_recv(struct jsonrpc_session *s)
}
if (msg) {
- if (msg->type == JSONRPC_REQUEST && !strcmp(msg->method, "echo")) {
+ if (msg->type == JSONRPC_REQUEST &&
+ nullable_string_is_equal(msg->method, "echo")) {
/* Echo request. Send reply. */
struct jsonrpc_msg *reply;
@@ -1204,7 +1205,8 @@ jsonrpc_session_recv(struct jsonrpc_session *s)
jsonrpc_session_send(s, reply);
} else if (msg->type == JSONRPC_REPLY
&& msg->id && msg->id->type == JSON_STRING
- && !strcmp(json_string(msg->id), "echo")) {
+ && nullable_string_is_equal(json_string(msg->id),
+ "echo")) {
/* It's a reply to our echo request. Suppress it. */
} else {
return msg;
--
2.53.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev