Print this page
OS-1576 Sundry uninitialised variables
Reviewed by: Robert Mustacchi <rm@joyent.com>

@@ -1119,11 +1119,11 @@
         struct zone_devtab      ztab;
         di_prof_t               prof = NULL;
         int                     err;
         int                     retval = -1;
         zone_iptype_t           iptype;
-        const char              *curr_iptype;
+        const char              *curr_iptype = NULL;
 
         if (di_prof_init(devpath, &prof)) {
                 zerror(zlogp, B_TRUE, "failed to initialize profile");
                 goto cleanup;
         }

@@ -1154,10 +1154,12 @@
                 break;
         case ZS_EXCLUSIVE:
                 curr_iptype = "exclusive";
                 break;
         }
+        if (curr_iptype == NULL)
+                abort();
 
         if (brand_platform_iter_devices(bh, zone_name,
             mount_one_dev_device_cb, prof, curr_iptype) != 0) {
                 zerror(zlogp, B_TRUE, "failed to add standard device");
                 goto cleanup;

@@ -3192,11 +3194,11 @@
         int error = -1;
         char *privname = NULL;
 
         if (ALT_MOUNT(mount_cmd)) {
                 zone_iptype_t   iptype;
-                const char      *curr_iptype;
+                const char      *curr_iptype = NULL;
 
                 if (zonecfg_get_iptype(snap_hndl, &iptype) != Z_OK) {
                         zerror(zlogp, B_TRUE, "unable to determine ip-type");
                         return (-1);
                 }

@@ -4497,11 +4499,11 @@
         char *kzone;
         FILE *fp = NULL;
         tsol_zcent_t *zcent = NULL;
         int match = 0;
         int doi = 0;
-        int flags;
+        int flags = -1;
         zone_iptype_t iptype;
 
         if (zone_get_rootpath(zone_name, rootpath, sizeof (rootpath)) != Z_OK) {
                 zerror(zlogp, B_TRUE, "unable to determine zone root");
                 return (-1);

@@ -4519,10 +4521,12 @@
                 break;
         case ZS_EXCLUSIVE:
                 flags = ZCF_NET_EXCL;
                 break;
         }
+        if (flags == -1)
+                abort();
 
         if ((privs = priv_allocset()) == NULL) {
                 zerror(zlogp, B_TRUE, "%s failed", "priv_allocset");
                 return (-1);
         }

@@ -4870,10 +4874,12 @@
                             0) {
                                 lofs_discard_mnttab();
                                 return (-1);
                         }
                         break;
+                default:
+                        abort();
                 }
         }
 
         write_index_file(zoneid);