diff --git a/src/freebsd_pci.c b/src/freebsd_pci.c index 3794328cd5ff0e3c0fae260f69d6e3b67ecb4240..709bfb6556fef6c43ee6eb823af40bc1b31f20dc 100644 --- a/src/freebsd_pci.c +++ b/src/freebsd_pci.c @@ -663,12 +663,14 @@ pci_system_freebsd_create( void ) if ( ioctl( pcidev, PCIOCGETCONF, &pciconfio ) == -1) { free( pci_sys ); + pci_sys = NULL; close( pcidev ); return errno; } if (pciconfio.status == PCI_GETCONF_ERROR ) { free( pci_sys ); + pci_sys = NULL; close( pcidev ); return EINVAL; } diff --git a/src/linux_devmem.h b/src/linux_devmem.h index e69557fec95193ede53e68ab8086edc78f0e93a8..0ae54527e58dd82cc9d61ab66ad7951c8940c516 100644 --- a/src/linux_devmem.h +++ b/src/linux_devmem.h @@ -30,5 +30,10 @@ * \author Ian Romanick */ +#ifndef LINUX_DEVMEM_H +#define LINUX_DEVMEM_H + extern int pci_device_linux_devmem_read_rom(struct pci_device *dev, void *buffer); + +#endif diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c index d79404ec0df5bedcf80fe4f1ec1d16fe15fb8a56..1b4051b60c59b71bae52bc67b160b699ebf3bba9 100644 --- a/src/linux_sysfs.c +++ b/src/linux_sysfs.c @@ -981,7 +981,7 @@ pci_device_linux_sysfs_map_legacy(struct pci_device *dev, pciaddr_t base, int ret=0; if (map_flags & PCI_DEV_MAP_FLAG_WRITABLE) { - flags = O_RDWR; /* O_RDWR != O_WRONLY | O_RDONLY */; + flags = O_RDWR; /* O_RDWR != O_WRONLY | O_RDONLY */ prot |= PROT_WRITE; } diff --git a/src/netbsd_pci.c b/src/netbsd_pci.c index 1f3bceacad9f5c47d0b405f9d45bcd0880067aec..b6a5ccdec0a6428d76dc79f12e7a2af0525267cb 100644 --- a/src/netbsd_pci.c +++ b/src/netbsd_pci.c @@ -942,6 +942,7 @@ pci_system_netbsd_create(void) for (i = 0; i < nbuses; i++) close(buses[i].fd); free(pci_sys); + pci_sys = NULL; return ENOMEM; } diff --git a/src/pci_tools.h b/src/pci_tools.h index 37668902b03f59cbea3fd42d1e6bc48cd846b2d6..47b121fd4232d824558a56a8031d1d3139b88498 100644 --- a/src/pci_tools.h +++ b/src/pci_tools.h @@ -165,7 +165,7 @@ typedef struct pcitool_intr_get { #define PCITOOL_IGET_SIZE(num_devs) \ (sizeof (pcitool_intr_get_t) - \ sizeof (pcitool_intr_dev_t) + \ - (num_devs * sizeof (pcitool_intr_dev_t))) + ((num_devs) * sizeof (pcitool_intr_dev_t))) /* * Size and endian fields for acc_attr bitmask. @@ -175,12 +175,12 @@ typedef struct pcitool_intr_get { #define PCITOOL_ACC_ATTR_SIZE_2 0x1 #define PCITOOL_ACC_ATTR_SIZE_4 0x2 #define PCITOOL_ACC_ATTR_SIZE_8 0x3 -#define PCITOOL_ACC_ATTR_SIZE(x) (1 << (x & PCITOOL_ACC_ATTR_SIZE_MASK)) +#define PCITOOL_ACC_ATTR_SIZE(x) (1 << ((x) & PCITOOL_ACC_ATTR_SIZE_MASK)) #define PCITOOL_ACC_ATTR_ENDN_MASK 0x100 #define PCITOOL_ACC_ATTR_ENDN_LTL 0x0 #define PCITOOL_ACC_ATTR_ENDN_BIG 0x100 -#define PCITOOL_ACC_IS_BIG_ENDIAN(x) (x & PCITOOL_ACC_ATTR_ENDN_BIG) +#define PCITOOL_ACC_IS_BIG_ENDIAN(x) ((x) & PCITOOL_ACC_ATTR_ENDN_BIG) /* * Data structure to read and write to pci device registers.