For some reason, MemorySanitizer thinks that the index is not
initialized when we hit the OPT_LOCAL option:

 WARNING: MemorySanitizer: use-of-uninitialized-value
  0 0x4c49d4 in parse_options utilities/ovs-vsctl.c:288:9
  1 0x4c3955 in main utilities/ovs-vsctl.c:167:5
  2 0x7f28e4 in __libc_start_call_main
  3 0x7f28e4 in __libc_start_main@GLIBC_2.2.5
  4 0x432b04 in _start (utilities/ovs-vsctl+0x432b04)

The value is initialized and the option works correctly, so I'm not
sure why the sanitizer is confused.  I saw similar reports from the
valgrind as well, IIRC...

Let's silence the warning by initializing to INT_MAX.  If it is not
actually initialized for some reason, at least it will crash and we'll
have a better idea on what is happening.

Signed-off-by: Ilya Maximets <[email protected]>
---
 utilities/ovs-vsctl.c | 2 +-
 vtep/vtep-ctl.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index 495be3565..edef0f18e 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -278,7 +278,7 @@ parse_options(int argc, char *argv[], struct shash 
*local_options)
     ctl_add_cmd_options(&options, &n_options, &allocated_options, OPT_LOCAL);
 
     for (;;) {
-        int idx;
+        int idx = INT_MAX;
         int c;
 
         c = getopt_long(argc, argv, short_options, options, &idx);
diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c
index 26b8540b4..880c95f0e 100644
--- a/vtep/vtep-ctl.c
+++ b/vtep/vtep-ctl.c
@@ -206,7 +206,7 @@ parse_options(int argc, char *argv[], struct shash 
*local_options)
     ctl_add_cmd_options(&options, &n_options, &allocated_options, OPT_LOCAL);
 
     for (;;) {
-        int idx;
+        int idx = INT_MAX;
         int c;
 
         c = getopt_long(argc, argv, short_options, options, &idx);
-- 
2.47.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to