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


 238         for (i = 0; i < nzids; i++) {
 239                 int res;
 240                 zone_status_t status;
 241 
 242                 /*
 243                  * Skip over zones that have gone away or are going down
 244                  * since we got the list.  Process all zones in the list,
 245                  * logging errors for any that failed.
 246                  */
 247                 if (zone_getattr(zids[i], ZONE_ATTR_STATUS, &status,
 248                     sizeof (status)) < 0)
 249                         continue;
 250                 switch (status) {
 251                         case ZONE_IS_SHUTTING_DOWN:
 252                         case ZONE_IS_EMPTY:
 253                         case ZONE_IS_DOWN:
 254                         case ZONE_IS_DYING:
 255                         case ZONE_IS_DEAD:
 256                                 /* FALLTHRU */
 257                                 continue;


 258                 }
 259                 if ((res = dlmgmt_zone_init(zids[i])) != 0) {
 260                         (void) fprintf(stderr, "zone (%ld) init error %s",
 261                             zids[i], strerror(res));
 262                         dlmgmt_log(LOG_ERR, "zone (%d) init error %s",
 263                             zids[i], strerror(res));
 264                 }
 265         }
 266         free(zids);
 267         return (0);
 268 }
 269 
 270 static int
 271 dlmgmt_init(void)
 272 {
 273         int     err;
 274         char    *fmri, *c;
 275         char    filename[MAXPATHLEN];
 276 
 277         if (dladm_open(&dld_handle) != DLADM_STATUS_OK) {




 238         for (i = 0; i < nzids; i++) {
 239                 int res;
 240                 zone_status_t status;
 241 
 242                 /*
 243                  * Skip over zones that have gone away or are going down
 244                  * since we got the list.  Process all zones in the list,
 245                  * logging errors for any that failed.
 246                  */
 247                 if (zone_getattr(zids[i], ZONE_ATTR_STATUS, &status,
 248                     sizeof (status)) < 0)
 249                         continue;
 250                 switch (status) {
 251                         case ZONE_IS_SHUTTING_DOWN:
 252                         case ZONE_IS_EMPTY:
 253                         case ZONE_IS_DOWN:
 254                         case ZONE_IS_DYING:
 255                         case ZONE_IS_DEAD:
 256                                 /* FALLTHRU */
 257                                 continue;
 258                         default:
 259                                 break;
 260                 }
 261                 if ((res = dlmgmt_zone_init(zids[i])) != 0) {
 262                         (void) fprintf(stderr, "zone (%ld) init error %s",
 263                             zids[i], strerror(res));
 264                         dlmgmt_log(LOG_ERR, "zone (%d) init error %s",
 265                             zids[i], strerror(res));
 266                 }
 267         }
 268         free(zids);
 269         return (0);
 270 }
 271 
 272 static int
 273 dlmgmt_init(void)
 274 {
 275         int     err;
 276         char    *fmri, *c;
 277         char    filename[MAXPATHLEN];
 278 
 279         if (dladm_open(&dld_handle) != DLADM_STATUS_OK) {