summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-09-21 08:04:01 +0100
committerRichard Hughes <richard@hughsie.com>2016-09-21 08:04:01 +0100
commitfcb2bd867482ada4bf967652e11e722b04792ece (patch)
tree90809a16f2e20368ad2f0048a182a91844daf3d4
parent9333a521c9c05db79c191b4e65a2260b7d907cb0 (diff)
downloadappstream-glib-fcb2bd867482ada4bf967652e11e722b04792ece.tar.gz
Fix the CSM rating age calculation
We want to return the *largest* minimum age for all the classification IDs.
-rw-r--r--libappstream-glib/as-content-rating.c6
-rw-r--r--libappstream-glib/as-self-test.c1
2 files changed, 4 insertions, 3 deletions
diff --git a/libappstream-glib/as-content-rating.c b/libappstream-glib/as-content-rating.c
index 510bcb4..6ec9cfd 100644
--- a/libappstream-glib/as-content-rating.c
+++ b/libappstream-glib/as-content-rating.c
@@ -243,7 +243,7 @@ as_content_rating_id_value_to_csm_age (const gchar *id, AsContentRatingValue val
* here. Some 13 year olds mey be fine with the concept of mutilation of body
* parts, others may get nightmares.
*
- * Returns: The age in years, or G_MAXUINT for no details.
+ * Returns: The age in years, 0 for no rating, or G_MAXUINT for no details.
*
* Since: 0.5.12
**/
@@ -252,7 +252,7 @@ as_content_rating_get_minimum_age (AsContentRating *content_rating)
{
AsContentRatingPrivate *priv = GET_PRIVATE (content_rating);
guint i;
- guint csm_age = G_MAXUINT;
+ guint csm_age = 0;
/* check kind */
if (g_strcmp0 (priv->kind, "oars-1.0") != 0)
@@ -263,7 +263,7 @@ as_content_rating_get_minimum_age (AsContentRating *content_rating)
guint csm_tmp;
key = g_ptr_array_index (priv->keys, i);
csm_tmp = as_content_rating_id_value_to_csm_age (key->id, key->value);
- if (csm_tmp > 0 && csm_tmp < csm_age)
+ if (csm_tmp > 0 && csm_tmp > csm_age)
csm_age = csm_tmp;
}
return csm_age;
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 46ceb94..892ad28 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -1444,6 +1444,7 @@ as_test_content_rating_func (void)
const gchar *src =
"<content_rating type=\"oars-1.0\">\n"
"<content_attribute id=\"drugs-alcohol\">moderate</content_attribute>\n"
+ "<content_attribute id=\"violence-cartoon\">mild</content_attribute>\n"
"</content_rating>\n";
gboolean ret;
g_autofree AsNodeContext *ctx = NULL;