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 <maciejx.t.gajdzica@intel.com>
This commit is contained in:
Maciej Gajdzica 2015-02-20 16:13:20 +00:00 committed by Thomas Monjalon
parent 4ad7a16a13
commit 444b872a76
4 changed files with 5 additions and 5 deletions

View File

@ -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;

View File

@ -43,7 +43,7 @@
#include <rte_malloc.h>
#include <rte_log.h>
#define ENIC_PAGE_ALIGN 4096ULL
#define ENIC_PAGE_ALIGN 4096UL
#define ENIC_ALIGN ENIC_PAGE_ALIGN
#define NAME_MAX 255
#define ETH_ALEN 6

View File

@ -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;

View File

@ -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);