projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tests: Make test_per_application_leaks more robust
[lttng-tools.git]
/
tests
/
utils
/
xml-utils
/
extract_xml.cpp
diff --git
a/tests/utils/xml-utils/extract_xml.cpp
b/tests/utils/xml-utils/extract_xml.cpp
index 80b895411ab45b864208d33f2b673a19e0fe0c7e..280f2ed0284b80736ce92485479c488ce75aad1b 100644
(file)
--- a/
tests/utils/xml-utils/extract_xml.cpp
+++ b/
tests/utils/xml-utils/extract_xml.cpp
@@
-24,6
+24,8
@@
* node;b;
* node;c;
*/
* node;b;
* node;c;
*/
+#include "common.hpp"
+
#include <common/defaults.hpp>
#include <libxml/parser.h>
#include <common/defaults.hpp>
#include <libxml/parser.h>
@@
-36,6
+38,8
@@
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
+namespace ll = lttng::libxml;
+
#if defined(LIBXML_XPATH_ENABLED)
static int opt_verbose;
#if defined(LIBXML_XPATH_ENABLED)
static int opt_verbose;
@@
-56,7
+60,7
@@
static int print_xpath_nodes(xmlDocPtr doc, xmlNodeSetPtr nodes, FILE *output)
int i;
xmlNodePtr cur;
int i;
xmlNodePtr cur;
- xmlChar *node_child_value_string =
NULL
;
+ xmlChar *node_child_value_string =
nullptr
;
LTTNG_ASSERT(output);
size = (nodes) ? nodes->nodeNr : 0;
LTTNG_ASSERT(output);
size = (nodes) ? nodes->nodeNr : 0;
@@
-135,7
+139,7
@@
static int register_lttng_namespace(xmlXPathContextPtr xpathCtx)
{
int ret;
xmlChar *prefix;
{
int ret;
xmlChar *prefix;
- xmlChar *ns =
NULL
;
+ xmlChar *ns =
nullptr
;
prefix = xmlCharStrdup("lttng");
if (!prefix) {
prefix = xmlCharStrdup("lttng");
if (!prefix) {
@@
-169,15
+173,22
@@
end:
static int extract_xpath(const char *xml_path, const xmlChar *xpath)
{
int ret;
static int extract_xpath(const char *xml_path, const xmlChar *xpath)
{
int ret;
- xmlDocPtr doc =
NULL
;
- xmlXPathContextPtr xpathCtx =
NULL
;
- xmlXPathObjectPtr xpathObj =
NULL
;
+ xmlDocPtr doc =
nullptr
;
+ xmlXPathContextPtr xpathCtx =
nullptr
;
+ xmlXPathObjectPtr xpathObj =
nullptr
;
LTTNG_ASSERT(xml_path);
LTTNG_ASSERT(xpath);
LTTNG_ASSERT(xml_path);
LTTNG_ASSERT(xpath);
+ ll::parser_ctx_uptr parserCtx{ xmlNewParserCtxt() };
+
+ if (!parserCtx) {
+ fprintf(stderr, "ERR: could not allocate an XML parser context\n");
+ return -1;
+ }
+
/* Parse the xml file */
/* Parse the xml file */
- doc = xml
ParseFile(xml_path
);
+ doc = xml
CtxtReadFile(parserCtx.get(), xml_path, nullptr, XML_PARSE_NOBLANKS
);
if (!doc) {
fprintf(stderr, "ERR parsing: xml file invalid \"%s\"\n", xml_path);
return -1;
if (!doc) {
fprintf(stderr, "ERR parsing: xml file invalid \"%s\"\n", xml_path);
return -1;
@@
-253,7
+264,6
@@
int main(int argc, char **argv)
/* Init libxml */
xmlInitParser();
/* Init libxml */
xmlInitParser();
- xmlKeepBlanksDefault(0);
if (access(argv[optind], F_OK)) {
fprintf(stderr, "ERR:%s\n", "Xml path not valid");
return -1;
if (access(argv[optind], F_OK)) {
fprintf(stderr, "ERR:%s\n", "Xml path not valid");
return -1;
This page took
0.026201 seconds
and
4
git commands to generate.