fix-iomem-arithmetic.patch (applied cleanly)
[pintos-anon] / src / devices / pci.c
index 2df8e2ae4022c8c203a3b2cfcbe5d5c13bf96e9d..cb368e1244b67d86d2a2d003f8667e100f49be30 100644 (file)
@@ -329,7 +329,7 @@ pci_reg_write8 (struct pci_io *pio, int reg, uint8_t data)
 
   if (pio->type == PCI_IO_MEM)
     {
-      ((uint8_t *) pio->addr.ptr)[reg] = data;
+      *((uint8_t *) (pio->addr.ptr + reg)) = data;
     }
   else if (pio->type == PCI_IO_PORT)
     {
@@ -349,7 +349,7 @@ pci_reg_read32 (struct pci_io *pio, int reg)
 
   if (pio->type == PCI_IO_MEM)
     {
-      ret = ((uint32_t *) pio->addr.ptr)[reg];
+      ret = *((uint32_t *) (pio->addr.ptr + reg));
     }
   else if (pio->type == PCI_IO_PORT)
     {
@@ -372,7 +372,7 @@ pci_reg_read16 (struct pci_io * pio, int reg)
   ret = 0;
   if (pio->type == PCI_IO_MEM)
     {
-      ret = ((uint16_t *) pio->addr.ptr)[reg];
+      ret = *((uint16_t *) (pio->addr.ptr + reg));
     }
   else if (pio->type == PCI_IO_PORT)
     {
@@ -395,7 +395,7 @@ pci_reg_read8 (struct pci_io * pio, int reg)
 
   if (pio->type == PCI_IO_MEM)
     {
-      ret = ((uint8_t *) pio->addr.ptr)[reg];
+      ret = *((uint8_t *) (pio->addr.ptr + reg));
     }
   else if (pio->type == PCI_IO_PORT)
     {