diff mbox series

[3/4] npu2: Remove side effects in assert() calls.

Message ID 20171109004411.9193-4-cyril.bur@au1.ibm.com
State Accepted
Headers show
Series Bug fix and coverity fixes | expand

Commit Message

Cyril Bur Nov. 9, 2017, 12:44 a.m. UTC
This likely looks intentional and will do the correct thing.

The correct behaviour does rely on the fact that skiboot has a custom
assert() which will always generate code. 'Regular' assert() can be made
to generate no code. If we were to do that with this code, the results
would be, interesting!

This patch will also keep Coverity happy which is nice.

Fixes: CID 145242, 172044 and 172045
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 hw/npu2.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Stewart Smith Nov. 14, 2017, 6:48 a.m. UTC | #1
Cyril Bur <cyril.bur@au1.ibm.com> writes:
> This likely looks intentional and will do the correct thing.
>
> The correct behaviour does rely on the fact that skiboot has a custom
> assert() which will always generate code. 'Regular' assert() can be made
> to generate no code. If we were to do that with this code, the results
> would be, interesting!
>
> This patch will also keep Coverity happy which is nice.
>
> Fixes: CID 145242, 172044 and 172045
> Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
> ---
>  hw/npu2.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

This patch merged as of 8ca2d61f3b4bac88d9d676bf305f1ee2956ce6ad
diff mbox series

Patch

diff --git a/hw/npu2.c b/hw/npu2.c
index d215b4ce..9f1bc143 100644
--- a/hw/npu2.c
+++ b/hw/npu2.c
@@ -1291,7 +1291,8 @@  static void npu2_probe_phb(struct dt_node *dn)
 	/* Retrieve chip id */
 	path = dt_get_path(dn);
 	gcid = dt_get_chip_id(dn);
-	assert(proc_chip = get_chip(gcid));
+	proc_chip = get_chip(gcid);
+	assert(proc_chip);
 	if ((proc_chip->ec_level & 0xf0) > 0x20) {
 		prerror("NPU2: unsupported ec level on Chip 0x%x!\n", gcid);
 		return;
@@ -1666,9 +1667,12 @@  static void npu2_add_interrupt_map(struct npu2 *p,
 	size_t map_size;
 	uint32_t mask[] = {0xff00, 0x0, 0x0, 0x7};
 
+	assert(p->phb.dt_node);
+	phb_dn = p->phb.dt_node;
+
 	npu2_phandle = dt_prop_get_u32(dn, "ibm,npcq");
-	assert((npu2_dn = dt_find_by_phandle(dt_root, npu2_phandle)));
-	assert((phb_dn = p->phb.dt_node));
+	npu2_dn = dt_find_by_phandle(dt_root, npu2_phandle);
+	assert(npu2_dn);
 	map_size = 7 * sizeof(*map) * p->total_devices;
 	map = malloc(map_size);
 	index = 0;