summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-08-03 13:30:09 +0100
committerRichard Hughes <richard@hughsie.com>2015-08-03 13:34:43 +0100
commit1caf5938041a187d570687cb6c4213e7762b704c (patch)
tree1eb7576dfe130c446178360c58676a389a92c9a7
parent4e0bdce7148c9e85011c6ef07ea2745ad9d873d4 (diff)
downloadappstream-glib-1caf5938041a187d570687cb6c4213e7762b704c.tar.gz
Remove another length argument
As ebassi pointed out, gchar* is NUL-terminated by definition...
-rw-r--r--libappstream-builder/plugins/asb-plugin-ibus-xml.c2
-rw-r--r--libappstream-glib/as-app-validate.c4
-rw-r--r--libappstream-glib/as-app.c2
-rw-r--r--libappstream-glib/as-node.c5
-rw-r--r--libappstream-glib/as-node.h1
-rw-r--r--libappstream-glib/as-self-test.c56
-rw-r--r--libappstream-glib/as-store.c4
-rw-r--r--libappstream-glib/as-store.h1
-rw-r--r--libappstream-glib/as-utils.c5
9 files changed, 35 insertions, 45 deletions
diff --git a/libappstream-builder/plugins/asb-plugin-ibus-xml.c b/libappstream-builder/plugins/asb-plugin-ibus-xml.c
index f14bc33..0638725 100644
--- a/libappstream-builder/plugins/asb-plugin-ibus-xml.c
+++ b/libappstream-builder/plugins/asb-plugin-ibus-xml.c
@@ -109,7 +109,7 @@ asb_plugin_process_filename (AsbPlugin *plugin,
}
/* parse contents */
- root = as_node_from_xml (valid_xml->str, -1,
+ root = as_node_from_xml (valid_xml->str,
AS_NODE_FROM_XML_FLAG_NONE,
error);
if (!ret)
diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c
index 65cdbc1..5549653 100644
--- a/libappstream-glib/as-app-validate.c
+++ b/libappstream-glib/as-app-validate.c
@@ -342,9 +342,7 @@ as_app_validate_description (const gchar *xml,
_cleanup_node_unref_ GNode *node = NULL;
/* parse xml */
- node = as_node_from_xml (xml, -1,
- AS_NODE_FROM_XML_FLAG_NONE,
- error);
+ node = as_node_from_xml (xml, AS_NODE_FROM_XML_FLAG_NONE, error);
if (node == NULL)
return FALSE;
helper->number_paragraphs = 0;
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index 53f164b..3a49cf1 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -4358,7 +4358,7 @@ as_app_parse_appdata_file (AsApp *app,
/* parse */
if (flags & AS_APP_PARSE_FLAG_KEEP_COMMENTS)
from_xml_flags |= AS_NODE_FROM_XML_FLAG_KEEP_COMMENTS;
- root = as_node_from_xml (data, len, from_xml_flags, &error_local);
+ root = as_node_from_xml (data, from_xml_flags, &error_local);
if (root == NULL) {
g_set_error (error,
AS_APP_ERROR,
diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c
index 954af0d..098eed8 100644
--- a/libappstream-glib/as-node.c
+++ b/libappstream-glib/as-node.c
@@ -437,6 +437,7 @@ as_node_to_xml_string (GString *xml,
/**
* as_node_reflow_text:
* @text: XML text data
+ * @text_len: length of @text
*
* Converts pretty-formatted source text into a format suitable for AppStream.
* This might include joining paragraphs, supressing newlines or doing other
@@ -677,7 +678,6 @@ as_node_passthrough_cb (GMarkupParseContext *context,
/**
* as_node_from_xml: (skip)
* @data: XML data
- * @data_len: Length of @data, or -1 if NULL terminated
* @flags: #AsNodeFromXmlFlags, e.g. %AS_NODE_FROM_XML_FLAG_NONE
* @error: A #GError or %NULL
*
@@ -689,7 +689,6 @@ as_node_passthrough_cb (GMarkupParseContext *context,
**/
GNode *
as_node_from_xml (const gchar *data,
- gssize data_len,
AsNodeFromXmlFlags flags,
GError **error)
{
@@ -716,7 +715,7 @@ as_node_from_xml (const gchar *data,
NULL);
ret = g_markup_parse_context_parse (ctx,
data,
- data_len,
+ -1,
&error_local);
if (!ret) {
g_set_error_literal (error,
diff --git a/libappstream-glib/as-node.h b/libappstream-glib/as-node.h
index e2d04be..af14723 100644
--- a/libappstream-glib/as-node.h
+++ b/libappstream-glib/as-node.h
@@ -152,7 +152,6 @@ void as_node_remove_attribute (GNode *node,
GString *as_node_to_xml (const GNode *node,
AsNodeToXmlFlags flags);
GNode *as_node_from_xml (const gchar *data,
- gssize data_len,
AsNodeFromXmlFlags flags,
GError **error)
G_GNUC_WARN_UNUSED_RESULT;
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 89f45c7..2090aa7 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -355,7 +355,7 @@ as_test_release_func (void)
release = as_release_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "release");
@@ -397,7 +397,7 @@ as_test_provide_func (void)
provide = as_provide_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "binary");
@@ -448,7 +448,7 @@ as_test_release_appstream_func (void)
release = as_release_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "release");
@@ -520,7 +520,7 @@ as_test_release_appdata_func (void)
release = as_release_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "release");
@@ -748,7 +748,7 @@ as_test_icon_func (void)
icon = as_icon_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "icon");
@@ -817,7 +817,7 @@ as_test_checksum_func (void)
csum = as_checksum_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "checksum");
@@ -907,7 +907,7 @@ as_test_icon_embedded_func (void)
icon = as_icon_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "icon");
@@ -971,7 +971,7 @@ as_test_image_func (void)
image = as_image_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "image");
@@ -1042,7 +1042,7 @@ as_test_bundle_func (void)
bundle = as_bundle_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "bundle");
@@ -1091,7 +1091,7 @@ as_test_screenshot_func (void)
screenshot = as_screenshot_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "screenshot");
@@ -1214,7 +1214,7 @@ as_test_app_func (void)
app = as_app_new ();
/* to object */
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "component");
@@ -1900,7 +1900,7 @@ as_test_app_no_markup_func (void)
app = as_app_new ();
/* to object */
- root = as_node_from_xml (src, -1,
+ root = as_node_from_xml (src,
AS_NODE_FROM_XML_FLAG_LITERAL_TEXT,
&error);
g_assert_no_error (error);
@@ -1968,7 +1968,7 @@ as_test_node_sort_func (void)
_cleanup_node_unref_ GNode *root = NULL;
_cleanup_string_free_ GString *str = NULL;
- root = as_node_from_xml ("<d>ddd</d><c>ccc</c><b>bbb</b><a>aaa</a>", -1, 0, &error);
+ root = as_node_from_xml ("<d>ddd</d><c>ccc</c><b>bbb</b><a>aaa</a>", 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
@@ -2041,17 +2041,17 @@ as_test_node_xml_func (void)
GString *xml;
/* invalid XML */
- root = as_node_from_xml ("<moo>", -1, 0, &error);
+ root = as_node_from_xml ("<moo>", 0, &error);
g_assert (root == NULL);
g_assert_error (error, AS_NODE_ERROR, AS_NODE_ERROR_FAILED);
g_clear_error (&error);
- root = as_node_from_xml ("<foo></bar>", -1, 0, &error);
+ root = as_node_from_xml ("<foo></bar>", 0, &error);
g_assert (root == NULL);
g_assert_error (error, AS_NODE_ERROR, AS_NODE_ERROR_FAILED);
g_clear_error (&error);
/* valid XML */
- root = as_node_from_xml (valid, -1, 0, &error);
+ root = as_node_from_xml (valid, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
@@ -2087,7 +2087,7 @@ as_test_node_xml_func (void)
as_node_unref (root);
/* convert all the children to XML */
- root = as_node_from_xml ("<p>One</p><p>Two</p>", -1, 0, &error);
+ root = as_node_from_xml ("<p>One</p><p>Two</p>", 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
g_assert_cmpint (g_node_n_nodes (root, G_TRAVERSE_ALL), ==, 3);
@@ -2098,7 +2098,7 @@ as_test_node_xml_func (void)
as_node_unref (root);
/* keep comments */
- root = as_node_from_xml (valid, -1,
+ root = as_node_from_xml (valid,
AS_NODE_FROM_XML_FLAG_KEEP_COMMENTS,
&error);
g_assert_no_error (error);
@@ -2112,7 +2112,7 @@ as_test_node_xml_func (void)
as_node_unref (root);
/* keep comment formatting */
- root = as_node_from_xml (valid, -1,
+ root = as_node_from_xml (valid,
AS_NODE_FROM_XML_FLAG_KEEP_COMMENTS |
AS_NODE_FROM_XML_FLAG_LITERAL_TEXT,
&error);
@@ -2133,7 +2133,7 @@ as_test_node_xml_func (void)
as_node_unref (root);
/* check comments are appended together */
- root = as_node_from_xml ("<!-- 1st -->\n<!-- 2nd -->\n<foo/>\n", -1,
+ root = as_node_from_xml ("<!-- 1st -->\n<!-- 2nd -->\n<foo/>\n",
AS_NODE_FROM_XML_FLAG_KEEP_COMMENTS |
AS_NODE_FROM_XML_FLAG_LITERAL_TEXT,
&error);
@@ -2249,7 +2249,7 @@ as_test_node_localized_wrap_func (void)
_cleanup_hashtable_unref_ GHashTable *hash = NULL;
_cleanup_node_unref_ GNode *root = NULL;
- root = as_node_from_xml (xml, -1, 0, &error);
+ root = as_node_from_xml (xml, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
@@ -2306,7 +2306,7 @@ as_test_node_localized_wrap2_func (void)
_cleanup_hashtable_unref_ GHashTable *hash = NULL;
_cleanup_node_unref_ GNode *root = NULL;
- root = as_node_from_xml (xml, -1, 0, &error);
+ root = as_node_from_xml (xml, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
@@ -2487,7 +2487,7 @@ as_test_store_embedded_func (void)
/* load AppStream file with embedded icon */
store = as_store_new ();
as_store_set_origin (store, "origin");
- ret = as_store_from_xml (store, xml_src, -1, "/tmp", &error);
+ ret = as_store_from_xml (store, xml_src, "/tmp", &error);
g_assert_no_error (error);
g_assert (ret);
@@ -2924,7 +2924,7 @@ as_test_store_versions_func (void)
"</release>"
"</releases>"
"</application>"
- "</applications>", -1, NULL, &error);
+ "</applications>", NULL, &error);
g_assert_no_error (error);
g_assert (ret);
g_assert_cmpfloat (as_store_get_api_version (store), <, 0.4 + 0.01);
@@ -2975,7 +2975,7 @@ as_test_store_versions_func (void)
"<component type=\"desktop\">"
"<id>test.desktop</id>"
"</component>"
- "</components>", -1, NULL, &error);
+ "</components>", NULL, &error);
g_assert_no_error (error);
g_assert (ret);
@@ -3017,7 +3017,7 @@ as_test_store_addons_func (void)
/* load a file to the store */
store = as_store_new ();
- ret = as_store_from_xml (store, xml, -1, NULL, &error);
+ ret = as_store_from_xml (store, xml, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
@@ -3067,7 +3067,7 @@ as_test_node_no_dup_c_func (void)
/* to object */
app = as_app_new ();
- root = as_node_from_xml (src, -1, 0, &error);
+ root = as_node_from_xml (src, 0, &error);
g_assert_no_error (error);
g_assert (root != NULL);
n = as_node_find (root, "application");
@@ -3541,7 +3541,7 @@ as_test_store_metadata_func (void)
_cleanup_object_unref_ AsStore *store = NULL;
store = as_store_new ();
- ret = as_store_from_xml (store, xml, -1, NULL, &error);
+ ret = as_store_from_xml (store, xml, NULL, &error);
g_assert_no_error (error);
g_assert (ret);
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index a10237d..06ebd17 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -1142,7 +1142,6 @@ as_store_from_file (AsStore *store,
* as_store_from_xml:
* @store: a #AsStore instance.
* @data: XML data
- * @data_len: Length of @data, or -1 if NULL terminated
* @icon_root: the icon path, or %NULL for the default.
* @error: A #GError or %NULL.
*
@@ -1159,7 +1158,6 @@ as_store_from_file (AsStore *store,
gboolean
as_store_from_xml (AsStore *store,
const gchar *data,
- gssize data_len,
const gchar *icon_root,
GError **error)
{
@@ -1168,7 +1166,7 @@ as_store_from_xml (AsStore *store,
g_return_val_if_fail (AS_IS_STORE (store), FALSE);
- root = as_node_from_xml (data, data_len,
+ root = as_node_from_xml (data,
AS_NODE_FROM_XML_FLAG_LITERAL_TEXT,
&error_local);
if (root == NULL) {
diff --git a/libappstream-glib/as-store.h b/libappstream-glib/as-store.h
index b289c7d..ab46d94 100644
--- a/libappstream-glib/as-store.h
+++ b/libappstream-glib/as-store.h
@@ -146,7 +146,6 @@ gboolean as_store_from_file (AsStore *store,
GError **error);
gboolean as_store_from_xml (AsStore *store,
const gchar *data,
- gssize data_len,
const gchar *icon_root,
GError **error);
gboolean as_store_load (AsStore *store,
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c
index 172b65c..6033328 100644
--- a/libappstream-glib/as-utils.c
+++ b/libappstream-glib/as-utils.c
@@ -203,10 +203,7 @@ as_markup_convert (const gchar *markup,
return g_strdup (markup);
/* load */
- root = as_node_from_xml (markup,
- -1,
- AS_NODE_FROM_XML_FLAG_NONE,
- error);
+ root = as_node_from_xml (markup, AS_NODE_FROM_XML_FLAG_NONE, error);
if (root == NULL)
return NULL;