[Ovirt-devel] [PATCH node] Fixed where sending no NICs returned an error result.

Darryl L. Pierce dpierce at redhat.com
Fri Apr 17 19:10:39 UTC 2009


If there are no NICs to send, then the result is set to success and then
returned.

If no NICs were sent due to the only NIC found being ignored, then a
default success is returned.

Otherwise, processing NICs works as desired.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 ovirt-identify-node/protocol.c |   48 ++++++++++++++++++++++++---------------
 1 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/ovirt-identify-node/protocol.c b/ovirt-identify-node/protocol.c
index 0382dac..1099ebb 100644
--- a/ovirt-identify-node/protocol.c
+++ b/ovirt-identify-node/protocol.c
@@ -176,26 +176,36 @@ send_nic_details(void)
 
     nic_info_ptr current = nic_info;
 
-    while (current != NULL) {
-      if((!management_interface) || (strcmp(management_interface, current->iface_name))) {
-	send_text("NIC");
-
-	if (!(get_text("NICINFO?")) &&
-	    (!send_value("MAC", current->mac_address)) &&
-	    (!send_value("BANDWIDTH", current->bandwidth)) &&
-            (!send_value("IFACE_NAME", current->iface_name)) &&
-            (!send_value("IP_ADDRESS", current->ip_address)) &&
-            (!send_value("NETMASK", current->netmask)) &&
-            (!send_value("BROADCAST", current->broadcast))) {
-	  send_text("ENDNIC");
-	  result = get_text("ACK NIC");
-        }
-
-        current = current->next;
-      } else {
-	current = current->next;
+    /* only send NIC details if we found NICs to process */
+    if(current) {
+      int sent_count = 0;
+      while (current != NULL) {
+	if((!management_interface) || (strcmp(management_interface, current->iface_name))) {
+	  send_text("NIC");
+
+	  if (!(get_text("NICINFO?")) &&
+	      (!send_value("MAC", current->mac_address)) &&
+	      (!send_value("BANDWIDTH", current->bandwidth)) &&
+	      (!send_value("IFACE_NAME", current->iface_name)) &&
+	      (!send_value("IP_ADDRESS", current->ip_address)) &&
+	      (!send_value("NETMASK", current->netmask)) &&
+	      (!send_value("BROADCAST", current->broadcast))) {
+	    send_text("ENDNIC");
+	    result = get_text("ACK NIC");
+	    sent_count++;
+	  }
+
+	  current = current->next;
+	} else {
+	  current = current->next;
+	}
       }
-    }
+
+      /* if no nics were sent, then set default success */
+      if( sent_count == 0)
+	result = 0;
+
+    } else { result = 0; }
 
     return result;
 }
-- 
1.6.0.6




More information about the ovirt-devel mailing list