From: Maciej Gajdzica Date: Fri, 20 Feb 2015 16:13:20 +0000 (+0000) Subject: enic: fix possible data loss X-Git-Tag: spdx-start~9373 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=444b872a76915a8fd3fbcba9311720f2246e696f;p=dpdk.git enic: fix possible data loss Field ig_vlan_strip_en in struct enic type is int. It is used only by function enic_set_nic_cfg which expects uint_8 as argument. Changed type of the field to prevent possible loss of precision. Macro GET_CONFIG passes result of sizeof operation to the function vnic_dev_spec. This function expects parameter of type unsigned int. Changed that parameter type to size_t in function declaration to prevent possible data loss. Define ENIC_ALIGN is used only by function rte_memzone_reserve_aligned, which expects argument of type unsigned. Defined constant is of type unsigned long long. Changed type to unsigned long to prevent possible loss of precision. In function writeq is written in two 32-bit long registers with writel function. When trying to write val >> 32, static code analysis tool reports that 64-bit value is passed to function expecting 32-bit value. Added cast to clear this warning. Issues found with static code analysis tool. Signed-off-by: Maciej Gajdzica --- diff --git a/lib/librte_pmd_enic/enic.h b/lib/librte_pmd_enic/enic.h index 57b9c80e9e..a50bff1498 100644 --- a/lib/librte_pmd_enic/enic.h +++ b/lib/librte_pmd_enic/enic.h @@ -110,7 +110,7 @@ struct enic { pthread_t err_intr_thread; int promisc; int allmulti; - int ig_vlan_strip_en; + uint8_t ig_vlan_strip_en; int link_status; u8 hw_ip_checksum; diff --git a/lib/librte_pmd_enic/enic_compat.h b/lib/librte_pmd_enic/enic_compat.h index 0670c1e34c..f3598ed68d 100644 --- a/lib/librte_pmd_enic/enic_compat.h +++ b/lib/librte_pmd_enic/enic_compat.h @@ -43,7 +43,7 @@ #include #include -#define ENIC_PAGE_ALIGN 4096ULL +#define ENIC_PAGE_ALIGN 4096UL #define ENIC_ALIGN ENIC_PAGE_ALIGN #define NAME_MAX 255 #define ETH_ALEN 6 diff --git a/lib/librte_pmd_enic/vnic/vnic_dev.c b/lib/librte_pmd_enic/vnic/vnic_dev.c index 38b7f25e59..f56673462e 100644 --- a/lib/librte_pmd_enic/vnic/vnic_dev.c +++ b/lib/librte_pmd_enic/vnic/vnic_dev.c @@ -474,7 +474,7 @@ static int vnic_dev_capable(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd) return !(err || a0); } -int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size, +int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, size_t size, void *value) { u64 a0, a1; diff --git a/lib/librte_pmd_enic/vnic/vnic_dev.h b/lib/librte_pmd_enic/vnic/vnic_dev.h index d1373a5b9d..f58335724c 100644 --- a/lib/librte_pmd_enic/vnic/vnic_dev.h +++ b/lib/librte_pmd_enic/vnic/vnic_dev.h @@ -55,7 +55,7 @@ static inline u64 readq(void __iomem *reg) static inline void writeq(u64 val, void __iomem *reg) { writel(val & 0xffffffff, reg); - writel(val >> 32, (char *)reg + 0x4UL); + writel((u32)(val >> 32), (char *)reg + 0x4UL); } #endif @@ -136,7 +136,7 @@ void vnic_dev_cmd_proxy_end(struct vnic_dev *vdev); int vnic_dev_fw_info(struct vnic_dev *vdev, struct vnic_devcmd_fw_info **fw_info); int vnic_dev_asic_info(struct vnic_dev *vdev, u16 *asic_type, u16 *asic_rev); -int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, unsigned int size, +int vnic_dev_spec(struct vnic_dev *vdev, unsigned int offset, size_t size, void *value); int vnic_dev_stats_clear(struct vnic_dev *vdev); int vnic_dev_stats_dump(struct vnic_dev *vdev, struct vnic_stats **stats);