diff mbox series

[ovs-dev,v2,7/8] db-ctl-base: Initialize the output variable in the ctx structure.

Message ID 85c69f387ee4998ca32a384f24b1b757e9f649b0.1716896375.git.echaudro@redhat.com
State Changes Requested
Headers show
Series Coverity fixes. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Eelco Chaudron May 28, 2024, 11:39 a.m. UTC
Coverity was flagged that the uninitialized output variable was used
in the ctl_context_init_command() function. This patch initializes
the variable.

In addition it also destroys the ds string in ctl_context_done()
in case it's not cleared properly.

Fixes: 07ff77ccb82a ("db-ctl-base: Make common database command code into library.")
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/db-ctl-base.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
index 3a8068b12..b3e9b92d1 100644
--- a/lib/db-ctl-base.c
+++ b/lib/db-ctl-base.c
@@ -2656,6 +2656,7 @@  ctl_context_init(struct ctl_context *ctx, struct ctl_command *command,
                  struct ovsdb_symbol_table *symtab,
                  void (*invalidate_cache_cb)(struct ctl_context *))
 {
+    ds_init(&ctx->output);
     if (command) {
         ctl_context_init_command(ctx, command, false);
     }
@@ -2688,6 +2689,7 @@  ctl_context_done(struct ctl_context *ctx,
         ctl_context_done_command(ctx, command);
     }
     invalidate_cache(ctx);
+    ds_destroy(&ctx->output);
 }
 
 char * OVS_WARN_UNUSED_RESULT