dpif: Fix uninitialized memory accesses.
authorBen Pfaff <blp@nicira.com>
Thu, 5 Mar 2009 18:46:33 +0000 (10:46 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 5 Mar 2009 18:46:33 +0000 (10:46 -0800)
Found by Valgrind.

This may fix some problems found by Dan.

lib/dpif.c

index 0c94de41993a1eb9e020860c837e7f218880cab7..eba08551eab6e4a233f93fc6d609e052c75a0fef 100644 (file)
@@ -82,18 +82,17 @@ static char *odp_actions_to_string(const union odp_action actions[],
 int
 dpif_open(const char *name, struct dpif *dpif)
 {
-    unsigned int minor;
     int listen_mask;
     int error;
 
     dpif->fd = -1;
 
-    error = name_to_minor(name, &minor);
+    error = name_to_minor(name, &dpif->minor);
     if (error) {
         return error;
     }
 
-    error = open_by_minor(minor, dpif);
+    error = open_by_minor(dpif->minor, dpif);
     if (error) {
         return error;
     }
@@ -101,11 +100,12 @@ dpif_open(const char *name, struct dpif *dpif)
     /* We can open the device, but that doesn't mean that it's been created.
      * If it hasn't been, then any command other than ODP_DP_CREATE will
      * return ENODEV.  Try something innocuous. */
+    listen_mask = 0;            /* Make Valgrind happy. */
     if (ioctl(dpif->fd, ODP_GET_LISTEN_MASK, &listen_mask)) {
         error = errno;
         if (error != ENODEV) {
             VLOG_WARN("dp%u: probe returned unexpected error: %s",
-                      minor, strerror(error));
+                      dpif->minor, strerror(error));
         }
         dpif_close(dpif);
         return error;