[PATCH 28/43] virInterfaceDefParseMtu: Use virXPathUInt instead of virXPathULong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the proper convertor function and refactor error reporting.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/interface_conf.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index b31fdce101..671b8b088f 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -113,17 +113,15 @@ static int
 virInterfaceDefParseMtu(virInterfaceDef *def,
                         xmlXPathContextPtr ctxt)
 {
-    unsigned long mtu;
-    int ret;
+    if (virXPathUInt("string(./mtu/@size)", ctxt, &def->mtu) == -2)
+        return -1;

-    ret = virXPathULong("string(./mtu/@size)", ctxt, &mtu);
-    if ((ret == -2) || ((ret == 0) && (mtu > 100000))) {
-        virReportError(VIR_ERR_XML_ERROR,
-                       "%s", _("interface mtu value is improper"));
+    if (def->mtu > 100000) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("value of the 'size' attribute of 'mtu' element must be at most 100000"));
         return -1;
-    } else if (ret == 0) {
-        def->mtu = (unsigned int) mtu;
     }
+
     return 0;
 }

-- 
2.37.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux