Print this page
8626 make pcplusmp and apix warning-free
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2013 Pluribus Networks, Inc.
+ * Copyright 2017 Joyent, Inc.
  */
 
 /*
  * apic_introp.c:
  *      Has code for Advanced DDI interrupt framework support.

@@ -39,10 +40,12 @@
 #include <sys/trap.h>
 #include <sys/pci.h>
 #include <sys/pci_intr_lib.h>
 #include <sys/apic_common.h>
 
+#define UCHAR_MAX       UINT8_MAX
+
 extern struct av_head autovect[];
 
 /*
  *      Local Function Prototypes
  */

@@ -224,12 +227,14 @@
                 while ((apic_vector_to_irq[i] == APIC_RESV_IRQ) &&
                     (i <= highest)) {
                         if (APIC_CHECK_RESERVE_VECTORS(i))
                                 break;
                         navail++;
-                        if (navail >= count)
-                                return (start);
+                        if (navail >= count) {
+                                ASSERT(start >= 0 && start <= UCHAR_MAX);
+                                return ((uchar_t)start);
+                        }
                         i++;
                 }
         }
         return (0);
 }

@@ -503,13 +508,13 @@
         uint32_t orig_cpu;
         ulong_t iflag;
         apic_irq_t *irqps[PCI_MSI_MAX_INTRS];
         int i;
         int cap_ptr;
-        int msi_mask_off;
+        int msi_mask_off = 0;
         ushort_t msi_ctrl;
-        uint32_t msi_pvm;
+        uint32_t msi_pvm = 0;
         ddi_acc_handle_t handle;
         int num_vectors = 0;
         uint32_t vector;
 
         DDI_INTR_IMPLDBG((CE_CONT, "APIC_GRP_SET_CPU\n"));

@@ -639,11 +644,11 @@
 int
 apic_get_vector_intr_info(int vecirq, apic_get_intr_t *intr_params_p)
 {
         struct autovec *av_dev;
         uchar_t irqno;
-        int i;
+        uint i;
         apic_irq_t *irq_p;
 
         /* Sanity check the vector/irq argument. */
         ASSERT((vecirq >= 0) || (vecirq <= APIC_MAX_VECTOR));
 

@@ -655,11 +660,11 @@
          */
         if ((intr_params_p->avgi_req_flags & PSMGI_INTRBY_FLAGS) ==
             PSMGI_INTRBY_VEC)
                 irqno = apic_vector_to_irq[vecirq];
         else
-                irqno = vecirq;
+                irqno = (uchar_t)vecirq;
 
         irq_p = apic_irq_table[irqno];
 
         if ((irq_p == NULL) ||
             ((irq_p->airq_mps_intr_index != RESERVE_INDEX) &&

@@ -698,11 +703,11 @@
                         for (i = 0, av_dev = autovect[irqno].avh_link;
                             av_dev; av_dev = av_dev->av_link)
                                 if (av_dev->av_vector && av_dev->av_dip)
                                         i++;
                         intr_params_p->avgi_num_devs =
-                            MIN(intr_params_p->avgi_num_devs, i);
+                            (uchar_t)MIN(intr_params_p->avgi_num_devs, i);
                 }
 
                 /* There are no viable dips to return. */
                 if (intr_params_p->avgi_num_devs == 0)
                         intr_params_p->avgi_dip_list = NULL;