Print this page
OS-1572 Explicitly handle all possible enum values in switches
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zoneadmd/zoneadmd.c
          +++ new/usr/src/cmd/zoneadmd/zoneadmd.c
↓ open down ↓ 1524 lines elided ↑ open up ↑
1525 1525                          /*
1526 1526                           * We could have two clients racing to ready this
1527 1527                           * zone; the second client loses, but his request
1528 1528                           * doesn't fail, since the zone is now in the desired
1529 1529                           * state.
1530 1530                           */
1531 1531                          zerror(zlogp, B_FALSE, "zone is already ready");
1532 1532                          rval = 0;
1533 1533                          break;
1534 1534                  case Z_BOOT:
     1535 +                case Z_FORCEBOOT:
1535 1536                          (void) strlcpy(boot_args, zargp->bootbuf,
1536 1537                              sizeof (boot_args));
1537 1538                          eventstream_write(Z_EVT_ZONE_BOOTING);
1538 1539                          rval = zone_bootup(zlogp, zargp->bootbuf, zstate,
1539 1540                              debug);
1540 1541                          audit_put_record(zlogp, uc, rval, "boot");
1541 1542                          if (rval != 0) {
1542 1543                                  bringup_failure_recovery = B_TRUE;
1543 1544                                  (void) zone_halt(zlogp, B_FALSE, B_TRUE,
1544 1545                                      zstate, debug);
↓ open down ↓ 5 lines elided ↑ open up ↑
1550 1551                          if (kernelcall) /* Invalid; can't happen */
1551 1552                                  abort();
1552 1553                          if ((rval = zone_halt(zlogp, B_FALSE, B_FALSE, zstate,
1553 1554                              debug)) != 0)
1554 1555                                  break;
1555 1556                          eventstream_write(Z_EVT_ZONE_HALTED);
1556 1557                          break;
1557 1558                  case Z_REBOOT:
1558 1559                  case Z_NOTE_UNINSTALLING:
1559 1560                  case Z_MOUNT:
     1561 +                case Z_FORCEMOUNT:
1560 1562                  case Z_UNMOUNT:
1561 1563                          if (kernelcall) /* Invalid; can't happen */
1562 1564                                  abort();
1563 1565                          zerror(zlogp, B_FALSE, "%s operation is invalid "
1564 1566                              "for zones in state '%s'", z_cmd_name(cmd),
1565 1567                              zone_state_str(zstate));
1566 1568                          rval = -1;
1567 1569                          break;
1568 1570                  }
1569 1571                  break;
↓ open down ↓ 28 lines elided ↑ open up ↑
1598 1600                          if ((rval = zone_halt(zlogp, B_FALSE, B_TRUE, zstate,
1599 1601                              debug)) != 0)
1600 1602                                  break;
1601 1603                          if ((rval = zone_ready(zlogp, Z_MNT_BOOT, zstate,
1602 1604                              debug)) == 0)
1603 1605                                  eventstream_write(Z_EVT_ZONE_READIED);
1604 1606                          else
1605 1607                                  eventstream_write(Z_EVT_ZONE_HALTED);
1606 1608                          break;
1607 1609                  case Z_BOOT:
     1610 +                case Z_FORCEBOOT:
1608 1611                          /*
1609 1612                           * We could have two clients racing to boot this
1610 1613                           * zone; the second client loses, but his request
1611 1614                           * doesn't fail, since the zone is now in the desired
1612 1615                           * state.
1613 1616                           */
1614 1617                          zerror(zlogp, B_FALSE, "zone is already booted");
1615 1618                          rval = 0;
1616 1619                          break;
1617 1620                  case Z_HALT:
↓ open down ↓ 23 lines elided ↑ open up ↑
1641 1644                          audit_put_record(zlogp, uc, rval, "reboot");
1642 1645                          if (rval != 0) {
1643 1646                                  (void) zone_halt(zlogp, B_FALSE, B_TRUE,
1644 1647                                      zstate, debug);
1645 1648                                  eventstream_write(Z_EVT_ZONE_BOOTFAILED);
1646 1649                          }
1647 1650                          boot_args[0] = '\0';
1648 1651                          break;
1649 1652                  case Z_NOTE_UNINSTALLING:
1650 1653                  case Z_MOUNT:
     1654 +                case Z_FORCEMOUNT:
1651 1655                  case Z_UNMOUNT:
1652 1656                          zerror(zlogp, B_FALSE, "%s operation is invalid "
1653 1657                              "for zones in state '%s'", z_cmd_name(cmd),
1654 1658                              zone_state_str(zstate));
1655 1659                          rval = -1;
1656 1660                          break;
1657 1661                  }
1658 1662                  break;
1659 1663          default:
1660 1664                  abort();
↓ open down ↓ 782 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX