Skip to contentSkip to conversation

hw/versatilepb, realview: Fix condition for instantiation of onboard NIC

PATCH Applied Peter Maydell 2 participants 2 messages Mar 22, 2011 – Apr 1, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/versatilepb, realview: Fix condition for instantiation of onboard NIC

Correct the condition determining whether we instantiate the onboard NIC or a PCI card NIC on VersatilePB and Realview boards. This was broken in two ways:
(1) if the user asked for two default NICs ("-net nic -net nic") we would
crash trying to strcmp() a NULL pointer
(2) if the user asked for two NICs explicitly of the same model as the
onboard NIC (eg "-net nic,model=smc91c111 -net nic,model=smc91c111") we would try to instantiate two onboard NICs at the same address.

---
 hw/realview.c    |    4 ++--
 hw/versatilepb.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/realview.c +2 -2
index a67861e..96fb9da 100644
@@ -288,8 +288,8 @@ static void realview_init(ram_addr_t ram_size,
     for(n = 0; n < nb_nics; n++) {
         nd = &nd_table[n];
 
-        if ((!nd->model && !done_nic)
-            || strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0) {
+        if (!done_nic && (!nd->model ||
+                    strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0)) {
             if (is_pb) {
                 lan9118_init(nd, 0x4e000000, pic[28]);
             } else {
hw/versatilepb.c +1 -1
index 9f1bfcf..46b6a3f 100644
@@ -223,7 +223,7 @@ static void versatile_init(ram_addr_t ram_size,
     for(n = 0; n < nb_nics; n++) {
         nd = &nd_table[n];
 
-        if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
+        if (!done_smc && (!nd->model || strcmp(nd->model, "smc91c111") == 0)) {
             smc91c111_init(nd, 0x10010000, sic[25]);
             done_smc = 1;
         } else {
Signature · 1 line
1.7.1
#1 lore raw
Quoted 9 lines · Peter Maydell

Correct the condition determining whether we instantiate the onboard NIC or a PCI card NIC on VersatilePB and Realview boards. This was broken in two ways:
(1) if the user asked for two default NICs ("-net nic -net nic") we would
crash trying to strcmp() a NULL pointer
(2) if the user asked for two NICs explicitly of the same model as the
onboard NIC (eg "-net nic,model=smc91c111 -net nic,model=smc91c111") we would try to instantiate two onboard NICs at the same address.

Quoted 5 lines
---
 hw/realview.c    |    4 ++--
 hw/versatilepb.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Thanks, applied.

Quoted 33 lines
hw/realview.c +2 -2
index a67861e..96fb9da 100644
@@ -288,8 +288,8 @@ static void realview_init(ram_addr_t ram_size,
     for(n = 0; n < nb_nics; n++) {
         nd = &nd_table[n];
 
-        if ((!nd->model && !done_nic)
-            || strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0) {
+        if (!done_nic && (!nd->model ||
+                    strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0)) {
             if (is_pb) {
                 lan9118_init(nd, 0x4e000000, pic[28]);
             } else {
hw/versatilepb.c +1 -1
index 9f1bfcf..46b6a3f 100644
@@ -223,7 +223,7 @@ static void versatile_init(ram_addr_t ram_size,
     for(n = 0; n < nb_nics; n++) {
         nd = &nd_table[n];
 
-        if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) {
+        if (!done_smc && (!nd->model || strcmp(nd->model, "smc91c111") == 0)) {
             smc91c111_init(nd, 0x10010000, sic[25]);
             done_smc = 1;
         } else {
Signature · 1 line
1.7.1
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net