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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zoneadmd/vplat.c
          +++ new/usr/src/cmd/zoneadmd/vplat.c
↓ open down ↓ 1113 lines elided ↑ open up ↑
1114 1114  static int
1115 1115  mount_one_dev(zlog_t *zlogp, char *devpath, zone_mnt_t mount_cmd)
1116 1116  {
1117 1117          char                    brand[MAXNAMELEN];
1118 1118          brand_handle_t          bh = NULL;
1119 1119          struct zone_devtab      ztab;
1120 1120          di_prof_t               prof = NULL;
1121 1121          int                     err;
1122 1122          int                     retval = -1;
1123 1123          zone_iptype_t           iptype;
1124      -        const char              *curr_iptype;
     1124 +        const char              *curr_iptype = NULL;
1125 1125  
1126 1126          if (di_prof_init(devpath, &prof)) {
1127 1127                  zerror(zlogp, B_TRUE, "failed to initialize profile");
1128 1128                  goto cleanup;
1129 1129          }
1130 1130  
1131 1131          /*
1132 1132           * Get a handle to the brand info for this zone.
1133 1133           * If we are mounting the zone, then we must always use the default
1134 1134           * brand device mounts.
↓ open down ↓ 14 lines elided ↑ open up ↑
1149 1149                  goto cleanup;
1150 1150          }
1151 1151          switch (iptype) {
1152 1152          case ZS_SHARED:
1153 1153                  curr_iptype = "shared";
1154 1154                  break;
1155 1155          case ZS_EXCLUSIVE:
1156 1156                  curr_iptype = "exclusive";
1157 1157                  break;
1158 1158          }
     1159 +        if (curr_iptype == NULL)
     1160 +                abort();
1159 1161  
1160 1162          if (brand_platform_iter_devices(bh, zone_name,
1161 1163              mount_one_dev_device_cb, prof, curr_iptype) != 0) {
1162 1164                  zerror(zlogp, B_TRUE, "failed to add standard device");
1163 1165                  goto cleanup;
1164 1166          }
1165 1167  
1166 1168          if (brand_platform_iter_link(bh,
1167 1169              mount_one_dev_symlink_cb, prof) != 0) {
1168 1170                  zerror(zlogp, B_TRUE, "failed to add standard symlink");
↓ open down ↓ 2018 lines elided ↑ open up ↑
3187 3189  }
3188 3190  
3189 3191  static int
3190 3192  get_privset(zlog_t *zlogp, priv_set_t *privs, zone_mnt_t mount_cmd)
3191 3193  {
3192 3194          int error = -1;
3193 3195          char *privname = NULL;
3194 3196  
3195 3197          if (ALT_MOUNT(mount_cmd)) {
3196 3198                  zone_iptype_t   iptype;
3197      -                const char      *curr_iptype;
     3199 +                const char      *curr_iptype = NULL;
3198 3200  
3199 3201                  if (zonecfg_get_iptype(snap_hndl, &iptype) != Z_OK) {
3200 3202                          zerror(zlogp, B_TRUE, "unable to determine ip-type");
3201 3203                          return (-1);
3202 3204                  }
3203 3205  
3204 3206                  switch (iptype) {
3205 3207                  case ZS_SHARED:
3206 3208                          curr_iptype = "shared";
3207 3209                          break;
↓ open down ↓ 1284 lines elided ↑ open up ↑
4492 4494          size_t rctlbufsz = 0;
4493 4495          char *zfsbuf = NULL;
4494 4496          size_t zfsbufsz = 0;
4495 4497          zoneid_t zoneid = -1;
4496 4498          int xerr;
4497 4499          char *kzone;
4498 4500          FILE *fp = NULL;
4499 4501          tsol_zcent_t *zcent = NULL;
4500 4502          int match = 0;
4501 4503          int doi = 0;
4502      -        int flags;
     4504 +        int flags = -1;
4503 4505          zone_iptype_t iptype;
4504 4506  
4505 4507          if (zone_get_rootpath(zone_name, rootpath, sizeof (rootpath)) != Z_OK) {
4506 4508                  zerror(zlogp, B_TRUE, "unable to determine zone root");
4507 4509                  return (-1);
4508 4510          }
4509 4511          if (zonecfg_in_alt_root())
4510 4512                  resolve_lofs(zlogp, rootpath, sizeof (rootpath));
4511 4513  
4512 4514          if (vplat_get_iptype(zlogp, &iptype) < 0) {
↓ open down ↓ 1 lines elided ↑ open up ↑
4514 4516                  return (-1);
4515 4517          }
4516 4518          switch (iptype) {
4517 4519          case ZS_SHARED:
4518 4520                  flags = 0;
4519 4521                  break;
4520 4522          case ZS_EXCLUSIVE:
4521 4523                  flags = ZCF_NET_EXCL;
4522 4524                  break;
4523 4525          }
     4526 +        if (flags == -1)
     4527 +                abort();
4524 4528  
4525 4529          if ((privs = priv_allocset()) == NULL) {
4526 4530                  zerror(zlogp, B_TRUE, "%s failed", "priv_allocset");
4527 4531                  return (-1);
4528 4532          }
4529 4533          priv_emptyset(privs);
4530 4534          if (get_privset(zlogp, privs, mount_cmd) != 0)
4531 4535                  goto error;
4532 4536  
4533 4537          if (mount_cmd == Z_MNT_BOOT &&
↓ open down ↓ 331 lines elided ↑ open up ↑
4865 4869                          }
4866 4870                          break;
4867 4871                  case ZS_EXCLUSIVE:
4868 4872                          if (configure_exclusive_network_interfaces(zlogp,
4869 4873                              zoneid) !=
4870 4874                              0) {
4871 4875                                  lofs_discard_mnttab();
4872 4876                                  return (-1);
4873 4877                          }
4874 4878                          break;
     4879 +                default:
     4880 +                        abort();
4875 4881                  }
4876 4882          }
4877 4883  
4878 4884          write_index_file(zoneid);
4879 4885  
4880 4886          lofs_discard_mnttab();
4881 4887          return (0);
4882 4888  }
4883 4889  
4884 4890  static int
↓ open down ↓ 253 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX