[ovs-dev] [PATCH] db-ctl-base: Fix compilation warnings.

Ian Stokes ian.stokes at intel.com
Wed Jul 4 14:28:33 UTC 2018


This commit fixes uninitialized variable warnings in functions
cmd_create() and cmd_get() when compiling with gcc 6.3.1 and -Werror
by initializing variables 'symbol' and 'new' to NULL.

Cc: Alex Wang <alexw at nicira.com>
Fixes: 07ff77ccb82a ("db-ctl-base: Make common database command code
                      into library.")
Signed-off-by: Ian Stokes <ian.stokes at intel.com>
---
 lib/db-ctl-base.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
index a59ac30..1768b45 100644
--- a/lib/db-ctl-base.c
+++ b/lib/db-ctl-base.c
@@ -919,8 +919,8 @@ cmd_get(struct ctl_context *ctx)
     }
 
     if (id) {
-        struct ovsdb_symbol *symbol;
-        bool new;
+        struct ovsdb_symbol *symbol = NULL;
+        bool new = NULL;
 
         ctx->error = create_symbol(ctx->symtab, id, &symbol, &new);
         if (ctx->error) {
@@ -1698,7 +1698,7 @@ cmd_create(struct ctl_context *ctx)
     const char *table_name = ctx->argv[1];
     const struct ovsdb_idl_table_class *table;
     const struct ovsdb_idl_row *row;
-    const struct uuid *uuid;
+    const struct uuid *uuid = NULL;
     int i;
 
     ctx->error = get_table(table_name, &table);
@@ -1706,7 +1706,7 @@ cmd_create(struct ctl_context *ctx)
         return;
     }
     if (id) {
-        struct ovsdb_symbol *symbol;
+        struct ovsdb_symbol *symbol = NULL;
 
         ctx->error = create_symbol(ctx->symtab, id, &symbol, NULL);
         if (ctx->error) {
@@ -1719,8 +1719,6 @@ cmd_create(struct ctl_context *ctx)
             symbol->strong_ref = true;
         }
         uuid = &symbol->uuid;
-    } else {
-        uuid = NULL;
     }
 
     row = ovsdb_idl_txn_insert(ctx->txn, table, uuid);
-- 
2.7.5



More information about the dev mailing list