@@ -224,10 +224,10 @@ nfp_compute_bar(const struct nfp_bar *bar, uint32_t *bar_config,
newcfg |= offset >> bitsize;
- if (bar_base)
+ if (bar_base != NULL)
*bar_base = offset;
- if (bar_config)
+ if (bar_config != NULL)
*bar_config = newcfg;
return 0;
@@ -266,7 +266,7 @@ nfp_reconfigure_bar(struct nfp_pcie_user *nfp, struct nfp_bar *bar, int tgt,
err = nfp_compute_bar(bar, &newcfg, &newbase, tgt, act, tok, offset,
size, width);
- if (err)
+ if (err != 0)
return err;
bar->base = newbase;
@@ -515,7 +515,7 @@ nfp6000_area_read(struct nfp_cpp_area *area, void *kernel_vaddr,
return -EINVAL;
/* Unaligned? Translate to an explicit access */
- if ((priv->offset + offset) & (width - 1)) {
+ if (((priv->offset + offset) & (width - 1)) != 0) {
PMD_DRV_LOG(ERR, "aread_read unaligned!!!");
return -EINVAL;
}
@@ -583,7 +583,7 @@ nfp6000_area_write(struct nfp_cpp_area *area, const void *kernel_vaddr,
return -EINVAL;
/* Unaligned? Translate to an explicit access */
- if ((priv->offset + offset) & (width - 1))
+ if (((priv->offset + offset) & (width - 1)) != 0)
return -EINVAL;
is_64 = width == TARGET_WIDTH_64;
@@ -764,7 +764,7 @@ nfp6000_init(struct nfp_cpp *cpp, struct rte_pci_device *dev)
if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
cpp->driver_lock_needed) {
ret = nfp_acquire_process_lock(desc);
- if (ret)
+ if (ret != 0)
goto error;
}
@@ -235,7 +235,7 @@ nfp_cpp_area_alloc_acquire(struct nfp_cpp *cpp, uint32_t destination,
if (area == NULL)
return NULL;
- if (nfp_cpp_area_acquire(area)) {
+ if (nfp_cpp_area_acquire(area) != 0) {
nfp_cpp_area_free(area);
return NULL;
}
@@ -252,7 +252,7 @@ nfp_cpp_area_alloc_acquire(struct nfp_cpp *cpp, uint32_t destination,
void
nfp_cpp_area_free(struct nfp_cpp_area *area)
{
- if (area->cpp->op->area_cleanup)
+ if (area->cpp->op->area_cleanup != NULL)
area->cpp->op->area_cleanup(area);
free(area);
}
@@ -280,7 +280,7 @@ nfp_cpp_area_release_free(struct nfp_cpp_area *area)
int
nfp_cpp_area_acquire(struct nfp_cpp_area *area)
{
- if (area->cpp->op->area_acquire) {
+ if (area->cpp->op->area_acquire != NULL) {
int err = area->cpp->op->area_acquire(area);
if (err < 0)
@@ -299,7 +299,7 @@ nfp_cpp_area_acquire(struct nfp_cpp_area *area)
void
nfp_cpp_area_release(struct nfp_cpp_area *area)
{
- if (area->cpp->op->area_release)
+ if (area->cpp->op->area_release != NULL)
area->cpp->op->area_release(area);
}
@@ -319,7 +319,7 @@ nfp_cpp_area_iomem(struct nfp_cpp_area *area)
{
void *iomem = NULL;
- if (area->cpp->op->area_iomem)
+ if (area->cpp->op->area_iomem != NULL)
iomem = area->cpp->op->area_iomem(area);
return iomem;
@@ -621,10 +621,10 @@ nfp_cpp_alloc(struct rte_pci_device *dev, int driver_lock_needed)
void
nfp_cpp_free(struct nfp_cpp *cpp)
{
- if (cpp->op && cpp->op->free)
+ if (cpp->op != NULL && cpp->op->free != NULL)
cpp->op->free(cpp);
- if (cpp->serial_len)
+ if (cpp->serial_len != 0)
free(cpp->serial);
free(cpp);
@@ -833,7 +833,7 @@ __nfp_cpp_model_autodetect(struct nfp_cpp *cpp, uint32_t *model)
return err;
*model = reg & NFP_PL_DEVICE_MODEL_MASK;
- if (*model & NFP_PL_DEVICE_ID_MASK)
+ if ((*model & NFP_PL_DEVICE_ID_MASK) != 0)
*model -= 0x10;
return 0;
@@ -37,7 +37,7 @@ nfp_hwinfo_db_walk(struct nfp_hwinfo *hwinfo, uint32_t size)
{
const char *key, *val, *end = hwinfo->data + size;
- for (key = hwinfo->data; *key && key < end;
+ for (key = hwinfo->data; *key != 0 && key < end;
key = val + strlen(val) + 1) {
val = key + strlen(key) + 1;
if (val >= end) {
@@ -141,7 +141,7 @@ nfp_hwinfo_fetch(struct nfp_cpp *cpp, size_t *hwdb_size)
for (;;) {
db = nfp_hwinfo_try_fetch(cpp, hwdb_size);
- if (db)
+ if (db != NULL)
return db;
nanosleep(&wait, NULL);
@@ -164,7 +164,7 @@ nfp_hwinfo_read(struct nfp_cpp *cpp)
return NULL;
err = nfp_hwinfo_db_validate(db, hwdb_size);
- if (err) {
+ if (err != 0) {
free(db);
return NULL;
}
@@ -188,7 +188,7 @@ nfp_hwinfo_lookup(struct nfp_hwinfo *hwinfo, const char *lookup)
end = hwinfo->data + hwinfo->size - sizeof(uint32_t);
- for (key = hwinfo->data; *key && key < end;
+ for (key = hwinfo->data; *key != 0 && key < end;
key = val + strlen(val) + 1) {
val = key + strlen(key) + 1;
@@ -75,7 +75,7 @@ nfp_mip_read_resource(struct nfp_cpp *cpp, struct nfp_mip *mip)
return -ENODEV;
err = nfp_nffw_info_mip_first(nffw_info, &cpp_id, &addr);
- if (err)
+ if (err != 0)
goto exit_close_nffw;
err = nfp_mip_try_read(cpp, cpp_id, addr, mip);
@@ -105,7 +105,7 @@ nfp_mip_open(struct nfp_cpp *cpp)
return NULL;
err = nfp_mip_read_resource(cpp, mip);
- if (err) {
+ if (err != 0) {
free(mip);
return NULL;
}
@@ -38,7 +38,7 @@ static int
_nfp_cpp_mutex_validate(uint32_t model, int *target, unsigned long long address)
{
/* Address must be 64-bit aligned */
- if (address & 7)
+ if ((address & 7) != 0)
return -EINVAL;
if (NFP_CPP_MODEL_IS_6000(model)) {
@@ -190,7 +190,7 @@ nfp_nffw_info_fwid_first(struct nfp_nffw_info *state)
return NULL;
for (i = 0; i < cnt; i++)
- if (nffw_fwinfo_loaded_get(&fwinfo[i]))
+ if (nffw_fwinfo_loaded_get(&fwinfo[i]) != 0)
return &fwinfo[i];
return NULL;
@@ -217,7 +217,7 @@ nfp_nffw_info_mip_first(struct nfp_nffw_info *state, uint32_t *cpp_id,
*cpp_id = nffw_fwinfo_mip_cppid_get(fwinfo);
*off = nffw_fwinfo_mip_offset_get(fwinfo);
- if (nffw_fwinfo_mip_mu_da_get(fwinfo)) {
+ if (nffw_fwinfo_mip_mu_da_get(fwinfo) != 0) {
int locality_off;
if (NFP_CPP_ID_TARGET_of(*cpp_id) != NFP_CPP_TARGET_MU)
@@ -95,7 +95,7 @@ nfp_nsp_check(struct nfp_nsp *state)
return -EINVAL;
}
- if (reg & NSP_STATUS_BUSY) {
+ if ((reg & NSP_STATUS_BUSY) != 0) {
PMD_DRV_LOG(ERR, "Service processor busy!");
return -EBUSY;
}
@@ -128,7 +128,7 @@ nfp_nsp_open(struct nfp_cpp *cpp)
state->res = res;
err = nfp_nsp_check(state);
- if (err) {
+ if (err != 0) {
nfp_nsp_close(state);
return NULL;
}
@@ -219,7 +219,7 @@ nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option,
nsp_buffer = nsp_base + NSP_BUFFER;
err = nfp_nsp_check(state);
- if (err)
+ if (err != 0)
return err;
if (!FIELD_FIT(NSP_BUFFER_CPP, buff_cpp >> 8) ||
@@ -245,7 +245,7 @@ nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option,
/* Wait for NSP_COMMAND_START to go to 0 */
err = nfp_nsp_wait_reg(cpp, ®, nsp_cpp, nsp_command,
NSP_COMMAND_START, 0);
- if (err) {
+ if (err != 0) {
PMD_DRV_LOG(ERR, "Error %d waiting for code 0x%04x to start",
err, code);
return err;
@@ -254,7 +254,7 @@ nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option,
/* Wait for NSP_STATUS_BUSY to go to 0 */
err = nfp_nsp_wait_reg(cpp, ®, nsp_cpp, nsp_status, NSP_STATUS_BUSY,
0);
- if (err) {
+ if (err != 0) {
PMD_DRV_LOG(ERR, "Error %d waiting for code 0x%04x to start",
err, code);
return err;
@@ -266,7 +266,7 @@ nfp_nsp_command(struct nfp_nsp *state, uint16_t code, uint32_t option,
ret_val = FIELD_GET(NSP_COMMAND_OPTION, ret_val);
err = FIELD_GET(NSP_STATUS_RESULT, reg);
- if (err) {
+ if (err != 0) {
PMD_DRV_LOG(ERR, "Result (error) code set: %d (%d) command: %d",
-err, (int)ret_val, code);
nfp_nsp_print_extended_error(ret_val);
@@ -319,13 +319,13 @@ nfp_nsp_command_buf(struct nfp_nsp *nsp, uint16_t code, uint32_t option,
cpp_id = FIELD_GET(NSP_BUFFER_CPP, reg) << 8;
cpp_buf = FIELD_GET(NSP_BUFFER_ADDRESS, reg);
- if (in_buf && in_size) {
+ if (in_buf != NULL && in_size > 0) {
err = nfp_cpp_write(cpp, cpp_id, cpp_buf, in_buf, in_size);
if (err < 0)
return err;
}
/* Zero out remaining part of the buffer */
- if (out_buf && out_size && out_size > in_size) {
+ if (out_buf != NULL && out_size > 0 && out_size > in_size) {
memset(out_buf, 0, out_size - in_size);
err = nfp_cpp_write(cpp, cpp_id, cpp_buf + in_size, out_buf,
out_size - in_size);
@@ -337,7 +337,7 @@ nfp_nsp_command_buf(struct nfp_nsp *nsp, uint16_t code, uint32_t option,
if (ret < 0)
return ret;
- if (out_buf && out_size) {
+ if (out_buf != NULL && out_size > 0) {
err = nfp_cpp_read(cpp, cpp_id, cpp_buf, out_buf, out_size);
if (err < 0)
return err;
@@ -369,7 +369,7 @@ nfp_nsp_wait(struct nfp_nsp *state)
break;
}
}
- if (err)
+ if (err != 0)
PMD_DRV_LOG(ERR, "NSP failed to respond %d", err);
return err;
@@ -212,7 +212,7 @@ nfp_eth_port_translate(struct nfp_nsp *nsp, const union eth_table_entry *src,
dst->fec_modes_supported |= fec << NFP_FEC_BASER_BIT;
fec = FIELD_GET(NSP_ETH_PORT_FEC_SUPP_RS, port);
dst->fec_modes_supported |= fec << NFP_FEC_REED_SOLOMON_BIT;
- if (dst->fec_modes_supported)
+ if (dst->fec_modes_supported != 0)
dst->fec_modes_supported |= NFP_FEC_AUTO | NFP_FEC_DISABLED;
dst->fec = 1 << FIELD_GET(NSP_ETH_STATE_FEC, state);
@@ -285,7 +285,7 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp)
*/
for (i = 0; i < NSP_ETH_MAX_COUNT; i++) {
mac = (const struct rte_ether_addr *)entries[i].mac_addr;
- if ((entries[i].port & NSP_ETH_PORT_LANES_MASK) &&
+ if ((entries[i].port & NSP_ETH_PORT_LANES_MASK) != 0 &&
!rte_is_zero_ether_addr(mac))
cnt++;
}
@@ -294,7 +294,7 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp)
* those that give a port count, verify it against the value calculated
* above.
*/
- if (ret && ret != cnt) {
+ if (ret != 0 && ret != cnt) {
PMD_DRV_LOG(ERR, "table entry count (%d) unmatch entries present (%d)",
ret, cnt);
goto err;
@@ -309,7 +309,7 @@ __nfp_eth_read_ports(struct nfp_nsp *nsp)
table->count = cnt;
for (i = 0, j = 0; i < NSP_ETH_MAX_COUNT; i++) {
mac = (const struct rte_ether_addr *)entries[i].mac_addr;
- if ((entries[i].port & NSP_ETH_PORT_LANES_MASK) &&
+ if ((entries[i].port & NSP_ETH_PORT_LANES_MASK) != 0 &&
!rte_is_zero_ether_addr(mac))
nfp_eth_port_translate(nsp, &entries[i], i,
&table->ports[j++]);
@@ -621,7 +621,7 @@ nfp_eth_set_fec(struct nfp_cpp *cpp, unsigned int idx, enum nfp_eth_fec mode)
return -EIO;
err = __nfp_eth_set_fec(nsp, mode);
- if (err) {
+ if (err != 0) {
nfp_eth_config_cleanup_end(nsp);
return err;
}
@@ -115,15 +115,15 @@ nfp_resource_try_acquire(struct nfp_cpp *cpp, struct nfp_resource *res,
{
int err;
- if (nfp_cpp_mutex_lock(dev_mutex))
+ if (nfp_cpp_mutex_lock(dev_mutex) != 0)
return -EINVAL;
err = nfp_cpp_resource_find(cpp, res);
- if (err)
+ if (err != 0)
goto err_unlock_dev;
err = nfp_cpp_mutex_trylock(res->mutex);
- if (err)
+ if (err != 0)
goto err_res_mutex_free;
nfp_cpp_mutex_unlock(dev_mutex);
@@ -362,10 +362,10 @@ nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, int *error)
if (err)
err = -EIO;
exit:
- if (error)
+ if (error != NULL)
*error = err;
- if (err)
+ if (err != 0)
return ~0ULL;
return val;