summaryrefslogtreecommitdiff
path: root/ovn
diff options
context:
space:
mode:
authorIan Stokes <ian.stokes@intel.com>2018-07-25 15:00:43 +0100
committerBen Pfaff <blp@ovn.org>2018-07-31 12:52:17 -0700
commit14faed569586a7458134bd8140cb19833568c3b8 (patch)
tree8887b0873f3be4a034a98ce5060c5e356e6e61dc /ovn
parent82b261b9efdb7af4c2146178db10e901a9580f30 (diff)
downloadopenvswitch-14faed569586a7458134bd8140cb19833568c3b8.tar.gz
ovn-nbctl: Initialize arguments to avoid compilation warnings.
Output arguments for parse_priority() and dhcp_options_get() may not be initialized when either function returns an error. This causes compilation warnings for GCC 6.3.x regarding use of uninitialized variable use and null-pointer-arithmetic. Fix this by initializing priority_p* value to 0 for priority_parse() when an error occurs during parsing. For dhcp_options_get() set *dhcp_opts_p = dhcp_opts regardless as dhcp_opts will be equal to NULL when an error occurs within the function anyhow. Cc: Jakub Sitnicki <jkbs@redhat.com> Fixes: 3844c85de979 ("ovn-nbctl: Don't die in dhcp_options_get()." Fixes: bc8223df3b01 ("ovn-nbctl: Don't die in parse_priority().") Signed-off-by: Ian Stokes <ian.stokes@intel.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Jakub Sitnicki <jkbs@redhat.com>
Diffstat (limited to 'ovn')
-rw-r--r--ovn/utilities/ovn-nbctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index e4a2f25e7..c625546bb 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -1879,6 +1879,9 @@ parse_priority(const char *arg, int64_t *priority_p)
int64_t priority;
if (!ovs_scan(arg, "%"SCNd64, &priority)
|| priority < 0 || priority > 32767) {
+ /* Priority_p could be uninitialized as no valid priority was
+ * input, initialize it to a valid value of 0 before returning */
+ *priority_p = 0;
return xasprintf("%s: priority must in range 0...32767", arg);
}
*priority_p = priority;
@@ -3043,10 +3046,11 @@ dhcp_options_get(struct ctl_context *ctx, const char *id, bool must_exist,
dhcp_opts = nbrec_dhcp_options_get_for_uuid(ctx->idl, &dhcp_opts_uuid);
}
+ *dhcp_opts_p = dhcp_opts;
if (!dhcp_opts && must_exist) {
return xasprintf("%s: dhcp options UUID not found", id);
}
- *dhcp_opts_p = dhcp_opts;
+
return NULL;
}