const void *indices, unsigned *out_min_index,
                                unsigned *out_max_index)
 {
-   unsigned max = 0;
-   unsigned min = ~0u;
-
    switch (info->index_size) {
    case 4: {
       const unsigned *ui_indices = (const unsigned*)indices;
+      unsigned max = 0;
+      unsigned min = ~0u;
       if (info->primitive_restart) {
          for (unsigned i = 0; i < info->count; i++) {
             if (ui_indices[i] != info->restart_index) {
             if (ui_indices[i] < min) min = ui_indices[i];
          }
       }
+      *out_min_index = min;
+      *out_max_index = max;
       break;
    }
    case 2: {
       const unsigned short *us_indices = (const unsigned short*)indices;
+      unsigned short max = 0;
+      unsigned short min = ~((unsigned short)0);
       if (info->primitive_restart) {
          for (unsigned i = 0; i < info->count; i++) {
             if (us_indices[i] != info->restart_index) {
             if (us_indices[i] < min) min = us_indices[i];
          }
       }
+      *out_min_index = min;
+      *out_max_index = max;
       break;
    }
    case 1: {
       const unsigned char *ub_indices = (const unsigned char*)indices;
+      unsigned char max = 0;
+      unsigned char min = ~((unsigned char)0);
       if (info->primitive_restart) {
          for (unsigned i = 0; i < info->count; i++) {
             if (ub_indices[i] != info->restart_index) {
             if (ub_indices[i] < min) min = ub_indices[i];
          }
       }
+      *out_min_index = min;
+      *out_max_index = max;
       break;
    }
    default:
       assert(0);
    }
-
-   *out_min_index = min;
-   *out_max_index = max;
 }
 
 void u_vbuf_get_minmax_index(struct pipe_context *pipe,