Fix compilation on Ubuntu 14.04

A couple of problems appeared on Ubuntu 14.04 (gcc 4.8.4) when we
turned on additional compiler flags with commit
519c4285cf. This patch fixes these
problems by adhering to the strict anti-aliasing rules and also
initializing the 'tfd' variable where the compile believed it
_could_ be used uninitialized.

Signed-off-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
Geoffroy Van Cutsem
2018-04-09 13:53:27 +02:00
committed by Jack Ren
parent f98a7ca90a
commit da1c860e8c
2 changed files with 5 additions and 5 deletions

View File

@@ -270,14 +270,14 @@ static inline void
pci_set_cfgdata16(struct pci_vdev *pi, int offset, uint16_t val)
{
assert(offset <= (PCI_REGMAX - 1) && (offset & 1) == 0);
*(uint16_t *)(pi->cfgdata + offset) = val;
*(uint16_t *)((uint16_t *)pi->cfgdata + offset) = val;
}
static inline void
pci_set_cfgdata32(struct pci_vdev *pi, int offset, uint32_t val)
{
assert(offset <= (PCI_REGMAX - 3) && (offset & 3) == 0);
*(uint32_t *)(pi->cfgdata + offset) = val;
*(uint32_t *)((uint32_t *)pi->cfgdata + offset) = val;
}
static inline uint8_t
@@ -291,14 +291,14 @@ static inline uint16_t
pci_get_cfgdata16(struct pci_vdev *pi, int offset)
{
assert(offset <= (PCI_REGMAX - 1) && (offset & 1) == 0);
return (*(uint16_t *)(pi->cfgdata + offset));
return (*(uint16_t *)((uint16_t *)pi->cfgdata + offset));
}
static inline uint32_t
pci_get_cfgdata32(struct pci_vdev *pi, int offset)
{
assert(offset <= (PCI_REGMAX - 3) && (offset & 3) == 0);
return (*(uint32_t *)(pi->cfgdata + offset));
return (*(uint32_t *)((uint32_t *)pi->cfgdata + offset));
}
#endif /* _PCI_CORE_H_ */