[PATCH 12/12] util: xml: Remove virXMLPropStringLimit and virXPathStringLimit

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

 



The functions have very difficult semantics where callers are not able
to tell whether the property is missing or failed the length check. Only
the latter produces errors.

Since usage of the functions was phased out, remove them completely to
avoid further broken code.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/libvirt_private.syms |  2 --
 src/util/virxml.c        | 62 ----------------------------------------
 src/util/virxml.h        |  8 ------
 3 files changed, 72 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a7bc50a4d1..13b7266c97 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3625,7 +3625,6 @@ virXMLPropEnum;
 virXMLPropEnumDefault;
 virXMLPropInt;
 virXMLPropString;
-virXMLPropStringLimit;
 virXMLPropTristateBool;
 virXMLPropTristateSwitch;
 virXMLPropUInt;
@@ -3646,7 +3645,6 @@ virXPathNode;
 virXPathNodeSet;
 virXPathNumber;
 virXPathString;
-virXPathStringLimit;
 virXPathUInt;
 virXPathULong;
 virXPathULongHex;
diff --git a/src/util/virxml.c b/src/util/virxml.c
index b736d59d9c..4b09374107 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -89,45 +89,6 @@ virXPathString(const char *xpath,
 }


-static char *
-virXMLStringLimitInternal(char *value,
-                          size_t maxlen,
-                          const char *name)
-{
-    if (value != NULL && strlen(value) >= maxlen) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("'%s' value longer than '%zu' bytes"),
-                       name, maxlen);
-        VIR_FREE(value);
-        return NULL;
-    }
-
-    return value;
-}
-
-
-/**
- * virXPathStringLimit:
- * @xpath: the XPath string to evaluate
- * @maxlen: maximum length permitted string
- * @ctxt: an XPath context
- *
- * Wrapper for virXPathString, which validates the length of the returned
- * string.
- *
- * Returns a new string which must be deallocated by the caller or NULL if
- * the evaluation failed.
- */
-char *
-virXPathStringLimit(const char *xpath,
-                    size_t maxlen,
-                    xmlXPathContextPtr ctxt)
-{
-    char *tmp = virXPathString(xpath, ctxt);
-
-    return virXMLStringLimitInternal(tmp, maxlen, xpath);
-}
-
 /**
  * virXPathNumber:
  * @xpath: the XPath string to evaluate
@@ -492,29 +453,6 @@ virXMLPropString(xmlNodePtr node,
 }


-/**
- * virXMLPropStringLimit:
- * @node: XML dom node pointer
- * @name: Name of the property (attribute) to get
- * @maxlen: maximum permitted length of the string
- *
- * Wrapper for virXMLPropString, which validates the length of the returned
- * string.
- *
- * Returns a new string which must be deallocated by the caller or NULL if
- * the evaluation failed.
- */
-char *
-virXMLPropStringLimit(xmlNodePtr node,
-                      const char *name,
-                      size_t maxlen)
-{
-    char *tmp = (char *)xmlGetProp(node, BAD_CAST name);
-
-    return virXMLStringLimitInternal(tmp, maxlen, name);
-}
-
-
 /**
  * virXMLNodeContentString:
  * @node: XML dom node pointer
diff --git a/src/util/virxml.h b/src/util/virxml.h
index 06fb7aebd8..6f9f217f73 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -47,10 +47,6 @@ virXPathBoolean(const char *xpath,
 char *
 virXPathString(const char *xpath,
                xmlXPathContextPtr ctxt);
-char *
-virXPathStringLimit(const char *xpath,
-                    size_t maxlen,
-                    xmlXPathContextPtr ctxt);
 int
 virXPathNumber(const char *xpath,
                xmlXPathContextPtr ctxt,
@@ -98,10 +94,6 @@ char *
 virXMLPropString(xmlNodePtr node,
                  const char *name);
 char *
-virXMLPropStringLimit(xmlNodePtr node,
-                      const char *name,
-                      size_t maxlen);
-char *
 virXMLNodeContentString(xmlNodePtr node);

 int
-- 
2.31.1




[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