[libvirt] [PATCH 01/10] util: introduce virXMLPropStringLimit

Ján Tomko jtomko at redhat.com
Wed Aug 16 14:55:41 UTC 2017


On Wed, Aug 16, 2017 at 02:40:38PM +0200, Pavel Hrdina wrote:
>The virXMLPropStringLimit is an equivalent of virXPathStringLimit
>which should be preferred if you already have a XML dom node or
>if you need to parse more than one property.
>
>Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
>---
> src/libvirt_private.syms |  1 +
> src/util/virxml.c        | 52 +++++++++++++++++++++++++++++++++++++++---------
> src/util/virxml.h        |  3 +++
> 3 files changed, 47 insertions(+), 9 deletions(-)
>

ACK with one nit below

>@@ -506,6 +516,30 @@ virXMLPropString(xmlNodePtr node,
>     return (char *)xmlGetProp(node, BAD_CAST name);
> }
>
>+
>+/**
>+ * virXMLPropStringLimit:
>+ * @node: XML dom node pointer
>+ * @name: Name of the property (attribute) to get
>+ * @maxlen: maximum length permitted string

How about:
maximum permitted length of the string

Jan

>+ *
>+ * 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);
>+}
>+
>+
> /**
>  * virXPathBoolean:
>  * @xpath: the XPath string to evaluate
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170816/778094f1/attachment-0001.sig>


More information about the libvir-list mailing list