Skip to contentSkip to conversation

ppc/ppc405_boards: Remove unnecessary NULL check

PATCH Applied Philippe Mathieu-Daudé 4 participants 5 messages Mar 20, 2020 – Mar 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc/ppc405_boards: Remove unnecessary NULL check

This code is inside the "if (dinfo)" condition, so testing again here whether it is NULL is unnecessary.

Fixes dd59bcae7 (Don't size flash memory to match backing image)
Reported-by Coverity (CID 1421917)
---
 hw/ppc/ppc405_boards.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/ppc/ppc405_boards.c +3 -3
index e6bffb9e1a..6198ec1035 100644
@@ -191,7 +191,7 @@ static void ref405ep_init(MachineState *machine)
         bios_size = 8 * MiB;
         pflash_cfi02_register((uint32_t)(-bios_size),
                               "ef405ep.bios", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);
@@ -459,7 +459,7 @@ static void taihu_405ep_init(MachineState *machine)
         bios_size = 2 * MiB;
         pflash_cfi02_register(0xFFE00000,
                               "taihu_405ep.bios", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);
@@ -494,7 +494,7 @@ static void taihu_405ep_init(MachineState *machine)
     if (dinfo) {
         bios_size = 32 * MiB;
         pflash_cfi02_register(0xfc000000, "taihu_405ep.flash", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);
Signature · 1 line
2.21.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Philippe Mathieu-Daudé

This code is inside the "if (dinfo)" condition, so testing again here whether it is NULL is unnecessary.

Fixes dd59bcae7 (Don't size flash memory to match backing image)
Reported-by Coverity (CID 1421917)
---
 hw/ppc/ppc405_boards.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/ppc/ppc405_boards.c +2 -2
index e6bffb9e1a..6198ec1035 100644
@@ -191,7 +191,7 @@ static void ref405ep_init(MachineState *machine)
         bios_size = 8 * MiB;
         pflash_cfi02_register((uint32_t)(-bios_size),
                               "ef405ep.bios", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);
@@ -459,7 +459,7 @@ static void taihu_405ep_init(MachineState *machine)
         bios_size = 2 * MiB;
         pflash_cfi02_register(0xFFE00000,
                               "taihu_405ep.bios", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);

hw/ppc/ppc405_boards.c static void taihu_405ep_init(MachineState *machine) · line 500

Quoted 8 lines
hw/ppc/ppc405_boards.c +1 -1
@@ -494,7 +494,7 @@ static void taihu_405ep_init(MachineState *machine)
     if (dinfo) {
         bios_size = 32 * MiB;
         pflash_cfi02_register(0xfc000000, "taihu_405ep.flash", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);
Applied
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

This code is inside the "if (dinfo)" condition, so testing again here whether it is NULL is unnecessary.

Fixes dd59bcae7 (Don't size flash memory to match backing image)
Reported-by Coverity (CID 1421917)

Applied to ppc-for-5.1.

Quoted 35 lines
---
 hw/ppc/ppc405_boards.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/ppc/ppc405_boards.c +3 -3
index e6bffb9e1a..6198ec1035 100644
@@ -191,7 +191,7 @@ static void ref405ep_init(MachineState *machine)
         bios_size = 8 * MiB;
         pflash_cfi02_register((uint32_t)(-bios_size),
                               "ef405ep.bios", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);
@@ -459,7 +459,7 @@ static void taihu_405ep_init(MachineState *machine)
         bios_size = 2 * MiB;
         pflash_cfi02_register(0xFFE00000,
                               "taihu_405ep.bios", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);
@@ -494,7 +494,7 @@ static void taihu_405ep_init(MachineState *machine)
     if (dinfo) {
         bios_size = 32 * MiB;
         pflash_cfi02_register(0xfc000000, "taihu_405ep.flash", bios_size,
-                              dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
+                              blk_by_legacy_dinfo(dinfo),
                               64 * KiB, 1,
                               4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
                               1);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
Quoted 11 lines · David Gibson
Quoted 7 lines · Philippe Mathieu-Daudé

This code is inside the "if (dinfo)" condition, so testing again here whether it is NULL is unnecessary.

Fixes dd59bcae7 (Don't size flash memory to match backing image)
Reported-by Coverity (CID 1421917)

Applied to ppc-for-5.1.

This would be OK for 5.0 too at this stage.

thanks
-- PMM

#4 lore raw
Quoted 6 lines · Peter Maydell
Quoted 5 lines · David Gibson
Quoted 3 lines · Philippe Mathieu-Daudé

This code is inside the "if (dinfo)" condition, so testing again here whether it is NULL is unnecessary.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Fixes dd59bcae7 (Don't size flash memory to match backing image)
Reported-by Coverity (CID 1421917)

Applied to ppc-for-5.1.

This would be OK for 5.0 too at this stage.

Understood, I've moved this into the ppc-for-5.0 tree.

Quoted 4 lines

thanks
-- PMM

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson