>From 3ed550be22bcc350656368bcad3c00ae8406cf5f Mon Sep 17 00:00:00 2001
From: Laine Stump <laine@laine.org>
Date: Mon, 22 Apr 2013 14:02:14 -0400
Subject: [PATCH] things to squash in

---
 src/conf/network_conf.c | 64 ++++++++++++++++++++++---------------------------
 1 file changed, 29 insertions(+), 35 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 97c20e6..1c88547 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1136,30 +1136,26 @@ virNetworkIPDefParseXML(const char *networkName,
     def->family = virXPathString("string(./@family)", ctxt);
 
     address = virXPathString("string(./@address)", ctxt);
-    if (address) {
-        if (virSocketAddrParse(&def->address, address, AF_UNSPEC) < 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Bad address '%s' in definition of network '%s'"),
-                           address, networkName);
-            goto cleanup;
-        }
-
-    } else {
+    if (!address) {
         virReportError(VIR_ERR_XML_ERROR,
-                       _("Network address must be specified in definition of network '%s'"),
+                       _("Missing required address attribute in network '%s'"),
                        networkName);
         goto cleanup;
     }
+    if (virSocketAddrParse(&def->address, address, AF_UNSPEC) < 0) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Invalid address '%s' in network '%s'"),
+                       address, networkName);
+        goto cleanup;
+    }
 
     netmask = virXPathString("string(./@netmask)", ctxt);
-    if (netmask) {
-        if (virSocketAddrParse(&def->netmask, netmask, AF_UNSPEC) < 0) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Bad netmask '%s' in definition of network '%s'"),
-                           netmask, networkName);
-            goto cleanup;
-        }
-
+    if (netmask &&
+        (virSocketAddrParse(&def->netmask, netmask, AF_UNSPEC) < 0)) {
+        virReportError(VIR_ERR_XML_ERROR,
+                       _("Invalid netmask '%s' in network '%s'"),
+                       netmask, networkName);
+        goto cleanup;
     }
 
     prefixRc = virXPathULong("string(./@prefix)", ctxt, &prefix);
@@ -1186,47 +1182,45 @@ virNetworkIPDefParseXML(const char *networkName,
         if (netmask) {
             if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->netmask, AF_INET)) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                               _("network '%s' has invalid netmask '%s' for address '%s' (both must be IPv4)"),
-                               networkName, netmask, address);
+                               _("Invalid netmask '%s' for address '%s' "
+                                 "in network '%s' (both must be IPv4)"),
+                               netmask, address, networkName);
                 goto cleanup;
             }
             if (def->prefix > 0) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                               _("network '%s' cannot have both a prefix and a netmask"),
-                               networkName);
-                goto cleanup;
-            }
-        }
-        else {
-            if (def->prefix > 32 ) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                               _("Invalid IPv4 prefix '%lu'specified in network'%s'"),
-                               prefix, networkName);
+                               _("Network '%s' IP address cannot have "
+                                 "both a prefix and a netmask"), networkName);
                 goto cleanup;
             }
+        } else if (def->prefix > 32) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Invalid IPv4 prefix '%lu' in network '%s'"),
+                           prefix, networkName);
+            goto cleanup;
         }
     } else if (STREQ(def->family, "ipv6")) {
         if (!VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET6)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("family 'ipv6' specified for non-IPv6 address '%s' in network '%s'"),
+                           _("Family 'ipv6' specified for non-IPv6 address '%s' in network '%s'"),
                            address, networkName);
             goto cleanup;
         }
         if (netmask) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("specifying netmask invalid for IPv6 address '%s' in network '%s'"),
+                           _("netmask not allowed for IPv6 address '%s' in network '%s'"),
                            address, networkName);
             goto cleanup;
         }
-        if (def->prefix > 128 ) {
+        if (def->prefix > 128) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("Invalid IPv6 prefix '%lu'specified in network'%s'"),
+                           _("Invalid IPv6 prefix '%lu' in network '%s'"),
                            prefix, networkName);
             goto cleanup;
         }
     } else {
         virReportError(VIR_ERR_XML_ERROR,
-                       _("Unrecognized family '%s' in definition of network '%s'"),
+                       _("Unrecognized family '%s' in network '%s'"),
                        def->family, networkName);
         goto cleanup;
     }
-- 
1.7.11.7

