This commit fixes 'maybe-uninitialized' warnings for pointers in various
functions in ovn-nbctl when compiling with gcc 6.3.1 and -Werror.
Pointers to structs nbrec_logical_switch, nbrec_logical_switch_port,
nbrec_logical_router and nbrec_logical_router_port are now initialized
to NULL where required.

Cc: Justin Pettit <jpet...@ovn.org>
Cc: Venkata Anil <vkomm...@redhat.com>
Fixes: 31114af758c7 ("ovn-nbctl: Update logical router port commands.")
Fixes: 80f408f4cffb ("ovn: Use Logical_Switch_Port in NB.")
Fixes: 36f232bca2db ("ovn: l3ha, CLI for logical router port gateway
                      chassis")
Signed-off-by: Ian Stokes <ian.sto...@intel.com>
---
 ovn/utilities/ovn-nbctl.c | 66 +++++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index a98eacf..bca588a 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -885,7 +885,7 @@ nbctl_ls_del(struct ctl_context *ctx)
 {
     bool must_exist = !shash_find(&ctx->options, "--if-exists");
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch *ls;
+    const struct nbrec_logical_switch *ls = NULL;
 
     char *error = ls_by_name_or_uuid(ctx, id, must_exist, &ls);
     if (error) {
@@ -986,7 +986,7 @@ nbctl_lsp_add(struct ctl_context *ctx)
 {
     bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
 
-    const struct nbrec_logical_switch *ls;
+    const struct nbrec_logical_switch *ls = NULL;
     char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls);
     if (error) {
         ctx->error = error;
@@ -1113,7 +1113,7 @@ static void
 nbctl_lsp_del(struct ctl_context *ctx)
 {
     bool must_exist = !shash_find(&ctx->options, "--if-exists");
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], must_exist, &lsp);
     if (error) {
@@ -1170,7 +1170,7 @@ nbctl_lsp_list(struct ctl_context *ctx)
 static void
 nbctl_lsp_get_parent(struct ctl_context *ctx)
 {
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], true, &lsp);
     if (error) {
@@ -1184,7 +1184,7 @@ nbctl_lsp_get_parent(struct ctl_context *ctx)
 static void
 nbctl_lsp_get_tag(struct ctl_context *ctx)
 {
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, ctx->argv[1], true, &lsp);
     if (error) {
@@ -1199,7 +1199,7 @@ static void
 nbctl_lsp_set_addresses(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1229,7 +1229,7 @@ static void
 nbctl_lsp_get_addresses(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
     struct svec addresses;
     const char *mac;
     size_t i;
@@ -1254,7 +1254,7 @@ static void
 nbctl_lsp_set_port_security(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1268,7 +1268,7 @@ static void
 nbctl_lsp_get_port_security(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
     struct svec addrs;
     const char *addr;
     size_t i;
@@ -1292,7 +1292,7 @@ static void
 nbctl_lsp_get_up(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1323,7 +1323,7 @@ nbctl_lsp_set_enabled(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
     const char *state = ctx->argv[2];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1341,7 +1341,7 @@ static void
 nbctl_lsp_get_enabled(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1356,7 +1356,7 @@ nbctl_lsp_set_type(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
     const char *type = ctx->argv[2];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1376,7 +1376,7 @@ static void
 nbctl_lsp_get_type(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1389,7 +1389,7 @@ static void
 nbctl_lsp_set_options(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
     size_t i;
     struct smap options = SMAP_INITIALIZER(&options);
 
@@ -1416,7 +1416,7 @@ static void
 nbctl_lsp_get_options(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
     struct smap_node *node;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
@@ -1432,7 +1432,7 @@ static void
 nbctl_lsp_set_dhcpv4_options(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1459,7 +1459,7 @@ static void
 nbctl_lsp_set_dhcpv6_options(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1486,7 +1486,7 @@ static void
 nbctl_lsp_get_dhcpv4_options(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -1503,7 +1503,7 @@ static void
 nbctl_lsp_get_dhcpv6_options(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_switch_port *lsp;
+    const struct nbrec_logical_switch_port *lsp = NULL;
 
     char *error = lsp_by_name_or_uuid(ctx, id, true, &lsp);
     if (error) {
@@ -2321,7 +2321,7 @@ nbctl_lb_list(struct ctl_context *ctx)
 static void
 nbctl_lr_lb_add(struct ctl_context *ctx)
 {
-    const struct nbrec_logical_router *lr;
+    const struct nbrec_logical_router *lr = NULL;
     const struct nbrec_load_balancer *new_lb;
 
     char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr);
@@ -2442,7 +2442,7 @@ nbctl_lr_lb_list(struct ctl_context *ctx)
 static void
 nbctl_ls_lb_add(struct ctl_context *ctx)
 {
-    const struct nbrec_logical_switch *ls;
+    const struct nbrec_logical_switch *ls = NULL;
     const struct nbrec_load_balancer *new_lb;
 
     char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls);
@@ -2607,7 +2607,7 @@ nbctl_lr_del(struct ctl_context *ctx)
 {
     bool must_exist = !shash_find(&ctx->options, "--if-exists");
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_router *lr;
+    const struct nbrec_logical_router *lr = NULL;
 
     char *error = lr_by_name_or_uuid(ctx, id, must_exist, &lr);
     if (error) {
@@ -2816,7 +2816,7 @@ normalize_prefix_str(const char *orig_prefix)
 static void
 nbctl_lr_route_add(struct ctl_context *ctx)
 {
-    const struct nbrec_logical_router *lr;
+    const struct nbrec_logical_router *lr = NULL;
     char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr);
     if (error) {
         ctx->error = error;
@@ -2984,7 +2984,7 @@ nbctl_lr_route_del(struct ctl_context *ctx)
 static void
 nbctl_lr_nat_add(struct ctl_context *ctx)
 {
-    const struct nbrec_logical_router *lr;
+    const struct nbrec_logical_router *lr = NULL;
     const char *nat_type = ctx->argv[2];
     const char *external_ip = ctx->argv[3];
     const char *logical_ip = ctx->argv[4];
@@ -3120,7 +3120,7 @@ nbctl_lr_nat_add(struct ctl_context *ctx)
 static void
 nbctl_lr_nat_del(struct ctl_context *ctx)
 {
-    const struct nbrec_logical_router *lr;
+    const struct nbrec_logical_router *lr = NULL;
     bool must_exist = !shash_find(&ctx->options, "--if-exists");
     char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr);
     if (error) {
@@ -3318,7 +3318,7 @@ nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx)
     char *gc_name;
     int64_t priority = 0;
     const char *lrp_name = ctx->argv[1];
-    const struct nbrec_logical_router_port *lrp;
+    const struct nbrec_logical_router_port *lrp = NULL;
     char *error = lrp_by_name_or_uuid(ctx, lrp_name, true, &lrp);
     if (error) {
         ctx->error = error;
@@ -3396,7 +3396,7 @@ remove_gc(const struct nbrec_logical_router_port *lrp, 
size_t idx)
 static void
 nbctl_lrp_del_gateway_chassis(struct ctl_context *ctx)
 {
-    const struct nbrec_logical_router_port *lrp;
+    const struct nbrec_logical_router_port *lrp = NULL;
     char *error = lrp_by_name_or_uuid(ctx, ctx->argv[1], true, &lrp);
     if (error) {
         ctx->error = error;
@@ -3426,7 +3426,7 @@ static void
 nbctl_lrp_get_gateway_chassis(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_router_port *lrp;
+    const struct nbrec_logical_router_port *lrp = NULL;
     const struct nbrec_gateway_chassis **gcs;
     size_t i;
 
@@ -3451,7 +3451,7 @@ nbctl_lrp_add(struct ctl_context *ctx)
 {
     bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
 
-    const struct nbrec_logical_router *lr;
+    const struct nbrec_logical_router *lr = NULL;
     char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr);
     if (error) {
         ctx->error = error;
@@ -3619,7 +3619,7 @@ static void
 nbctl_lrp_del(struct ctl_context *ctx)
 {
     bool must_exist = !shash_find(&ctx->options, "--if-exists");
-    const struct nbrec_logical_router_port *lrp;
+    const struct nbrec_logical_router_port *lrp = NULL;
 
     char *error = lrp_by_name_or_uuid(ctx, ctx->argv[1], must_exist, &lrp);
     if (error) {
@@ -3680,7 +3680,7 @@ nbctl_lrp_set_enabled(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
     const char *state = ctx->argv[2];
-    const struct nbrec_logical_router_port *lrp;
+    const struct nbrec_logical_router_port *lrp = NULL;
 
     char *error = lrp_by_name_or_uuid(ctx, id, true, &lrp);
     if (error) {
@@ -3705,7 +3705,7 @@ static void
 nbctl_lrp_get_enabled(struct ctl_context *ctx)
 {
     const char *id = ctx->argv[1];
-    const struct nbrec_logical_router_port *lrp;
+    const struct nbrec_logical_router_port *lrp = NULL;
 
     char *error = lrp_by_name_or_uuid(ctx, id, true, &lrp);
     if (error) {
-- 
2.7.5

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to