summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-07-25 12:29:53 +0100
committerRichard Hughes <richard@hughsie.com>2016-07-25 12:29:53 +0100
commit74594acf6d9745b8ea0d4efbd58a4fc331f6ef46 (patch)
treefa31b9f18eea4396a1e247f20630334e42c9f046
parente04788886491aeb6ace2ba1d1161f0ce86c04a21 (diff)
downloadappstream-glib-74594acf6d9745b8ea0d4efbd58a4fc331f6ef46.tar.gz
Add two new GCC warnings and fix up signed/unsigned issues
-rw-r--r--client/as-builder.c6
-rw-r--r--client/as-compose.c4
-rw-r--r--client/as-util.c36
-rw-r--r--configure.ac2
-rw-r--r--libappstream-builder/asb-context.c2
-rw-r--r--libappstream-builder/asb-package-alpm.c6
-rw-r--r--libappstream-builder/asb-package-deb.c2
-rw-r--r--libappstream-builder/asb-package-rpm.c4
-rw-r--r--libappstream-builder/asb-package.c6
-rw-r--r--libappstream-builder/asb-package.h22
-rw-r--r--libappstream-builder/asb-self-test.c4
-rw-r--r--libappstream-builder/asb-task.c2
-rw-r--r--libappstream-builder/asb-utils.c2
-rw-r--r--libappstream-builder/plugins/asb-plugin-font.c9
-rw-r--r--libappstream-builder/plugins/asb-plugin-shell-extension.c2
-rw-r--r--libappstream-glib/as-app-builder.c4
-rw-r--r--libappstream-glib/as-app-validate.c24
-rw-r--r--libappstream-glib/as-app.c40
-rw-r--r--libappstream-glib/as-icon.c42
-rw-r--r--libappstream-glib/as-image.c115
-rw-r--r--libappstream-glib/as-image.h17
-rw-r--r--libappstream-glib/as-inf.c10
-rw-r--r--libappstream-glib/as-markup.c6
-rw-r--r--libappstream-glib/as-node.c62
-rw-r--r--libappstream-glib/as-node.h5
-rw-r--r--libappstream-glib/as-profile.c7
-rw-r--r--libappstream-glib/as-release.c6
-rw-r--r--libappstream-glib/as-screenshot.c8
-rw-r--r--libappstream-glib/as-self-test.c18
-rw-r--r--libappstream-glib/as-store-cab.c2
-rw-r--r--libappstream-glib/as-store.c8
-rw-r--r--libappstream-glib/as-tag.c2
-rw-r--r--libappstream-glib/as-utils.c32
-rw-r--r--libappstream-glib/as-yaml.c41
-rw-r--r--libappstream-glib/as-yaml.h1
35 files changed, 316 insertions, 243 deletions
diff --git a/client/as-builder.c b/client/as-builder.c
index d5ed90c..1833091 100644
--- a/client/as-builder.c
+++ b/client/as-builder.c
@@ -66,8 +66,8 @@ main (int argc, char **argv)
gboolean ret;
gboolean uncompressed_icons = FALSE;
gboolean verbose = FALSE;
- gint max_threads = 4;
- gint min_icon_size = 32;
+ guint max_threads = 4;
+ guint min_icon_size = 32;
guint i;
int retval = EXIT_SUCCESS;
g_autoptr(GDir) dir = NULL;
@@ -301,7 +301,7 @@ main (int argc, char **argv)
}
if (g_timer_elapsed (timer, NULL) > 3.f) {
/* TRANSLATORS: information message */
- g_print (_("Parsed %i/%i files..."), i, packages->len);
+ g_print (_("Parsed %u/%u files..."), i, packages->len);
g_print ("\n"),
g_timer_reset (timer);
}
diff --git a/client/as-compose.c b/client/as-compose.c
index ca13a43..5e57573 100644
--- a/client/as-compose.c
+++ b/client/as-compose.c
@@ -34,7 +34,7 @@ static void
as_compose_app_log (AsApp *app, const gchar *fmt, ...)
{
const gchar *id;
- guint i;
+ gsize i;
va_list args;
g_autofree gchar *tmp = NULL;
@@ -328,7 +328,7 @@ main (int argc, char **argv)
g_autoptr(AsStore) store = NULL;
g_autoptr(GFile) xml_dir = NULL;
g_autoptr(GFile) xml_file = NULL;
- gint min_icon_size = 32;
+ guint min_icon_size = 32;
guint i;
const GOptionEntry options[] = {
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
diff --git a/client/as-util.c b/client/as-util.c
index 7f2a10a..f72ebd1 100644
--- a/client/as-util.c
+++ b/client/as-util.c
@@ -110,8 +110,8 @@ static gchar *
as_util_get_descriptions (GPtrArray *array)
{
guint i;
- guint j;
- guint len;
+ gsize j;
+ gsize len;
const guint max_len = 35;
AsUtilItem *item;
GString *string;
@@ -649,7 +649,7 @@ as_util_appdata_to_news (AsUtilPrivate *priv, gchar **values, GError **error)
/* print release */
if (as_release_get_timestamp (rel) > 0) {
- dt = g_date_time_new_from_unix_utc (as_release_get_timestamp (rel));
+ dt = g_date_time_new_from_unix_utc ((gint64) as_release_get_timestamp (rel));
date = g_date_time_format (dt, "%F");
g_string_append_printf (str, "Released: %s\n\n", date);
}
@@ -1333,7 +1333,7 @@ as_util_show_search_tokens (AsUtilPrivate *priv, gchar **values, GError **error)
for (l = keys; l != NULL; l = l->next) {
tmp = l->data;
cnt = g_hash_table_lookup (dict, tmp);
- g_print ("%s [%i]\n", tmp, *cnt);
+ g_print ("%s [%u]\n", tmp, *cnt);
}
return TRUE;
@@ -1751,7 +1751,7 @@ as_util_status_html_write_exec_summary (GPtrArray *apps,
}
perc = 100.f * (gdouble) cnt / (gdouble) total;
g_string_append_printf (html, "<tr><td class=\"alt\">Keywords</td>"
- "<td>%i/%i</td><td class=\"thin\">%.1f%%</td></tr>\n",
+ "<td>%u/%u</td><td class=\"thin\">%.1f%%</td></tr>\n",
cnt, total, perc);
/* screenshots */
@@ -1765,7 +1765,7 @@ as_util_status_html_write_exec_summary (GPtrArray *apps,
}
perc = 100.f * (gdouble) cnt / (gdouble) total;
g_string_append_printf (html, "<tr><td class=\"alt\">Screenshots</td>"
- "<td>%i/%i</td><td class=\"thin\">%.1f%%</td></tr>\n",
+ "<td>%u/%u</td><td class=\"thin\">%.1f%%</td></tr>\n",
cnt, total, perc);
/* specific kudos */
@@ -1788,7 +1788,7 @@ as_util_status_html_write_exec_summary (GPtrArray *apps,
if (total > 0)
perc = 100.f * (gdouble) cnt / (gdouble) total;
g_string_append_printf (html, "<tr><td class=\"alt\">"
- "<i>%s</i></td><td>%i</td>"
+ "<i>%s</i></td><td>%u</td>"
"<td class=\"thin\">%.1f%%</td></tr>\n",
as_kudo_kind_to_string (j),
cnt, perc);
@@ -1802,7 +1802,7 @@ as_util_status_html_write_exec_summary (GPtrArray *apps,
cnt++;
}
g_string_append_printf (html, "<tr><td class=\"alt\">MetaInfo</td>"
- "<td>%i</td><td class=\"thin\"></td></tr>\n", cnt);
+ "<td>%u</td><td class=\"thin\"></td></tr>\n", cnt);
g_string_append (html, "</table>\n");
@@ -2461,7 +2461,7 @@ as_util_validate_output_text (const gchar *filename, GPtrArray *probs)
AsProblem *problem;
const gchar *tmp;
guint i;
- guint j;
+ gsize j;
/* success */
if (probs->len == 0) {
@@ -2479,7 +2479,7 @@ as_util_validate_output_text (const gchar *filename, GPtrArray *probs)
for (j = strlen (tmp); j < 20; j++)
g_print (" ");
if (as_problem_get_line_number (problem) > 0) {
- g_print (" : %s [ln:%i]\n",
+ g_print (" : %s [ln:%u]\n",
as_problem_get_message (problem),
as_problem_get_line_number (problem));
} else {
@@ -2516,7 +2516,7 @@ as_util_validate_output_html (const gchar *filename, GPtrArray *probs)
g_print ("<li>");
g_print ("%s\n", tmp);
if (as_problem_get_line_number (problem) > 0) {
- g_print (" (line %i)",
+ g_print (" (line %u)",
as_problem_get_line_number (problem));
}
g_print ("</li>\n");
@@ -2751,7 +2751,7 @@ static void
as_util_app_log (AsApp *app, const gchar *fmt, ...)
{
const gchar *id;
- guint i;
+ gsize i;
va_list args;
g_autofree gchar *tmp = NULL;
@@ -2787,7 +2787,7 @@ as_util_mirror_screenshots_thumb (AsScreenshot *ss, AsImage *im_src,
}
/* save to disk */
- size_str = g_strdup_printf ("%ix%i", width * scale, height * scale);
+ size_str = g_strdup_printf ("%ux%u", width * scale, height * scale);
fn = g_build_filename (output_dir, size_str,
as_image_get_basename (im_src),
NULL);
@@ -2854,7 +2854,7 @@ as_util_mirror_screenshots_app_file (AsApp *app,
g_set_error (error,
AS_APP_ERROR,
AS_APP_ERROR_FAILED,
- "%s is too small to be used: %ix%i",
+ "%s is too small to be used: %ux%u",
filename_no_path,
as_image_get_width (im_src),
as_image_get_height (im_src));
@@ -3105,7 +3105,7 @@ as_util_mirror_screenshots (AsUtilPrivate *priv, gchar **values, GError **error)
for (i = 0; sizes[i] != 0; i += 2) {
g_autofree gchar *size_str = NULL;
g_autofree gchar *fn = NULL;
- size_str = g_strdup_printf ("%ix%i",
+ size_str = g_strdup_printf ("%ux%u",
sizes[i+0] * j,
sizes[i+1] * j);
fn = g_build_filename (output_dir, size_str, NULL);
@@ -3301,7 +3301,7 @@ as_util_replace_screenshots (AsUtilPrivate *priv, gchar **values, GError **error
static void
as_util_pad_strings (const gchar *id, const gchar *msg, guint align)
{
- guint i;
+ gsize i;
g_print ("%s", id);
for (i = strlen (id); i < align; i++)
g_print (" ");
@@ -3740,7 +3740,7 @@ as_util_check_root (AsUtilPrivate *priv, gchar **values, GError **error)
g_set_error (error,
AS_ERROR,
AS_ERROR_FAILED,
- "Failed to check root, %i problems detected",
+ "Failed to check root, %u problems detected",
problems->len);
return FALSE;
}
@@ -3809,7 +3809,7 @@ main (int argc, char *argv[])
gboolean verbose = FALSE;
gboolean version = FALSE;
GError *error = NULL;
- guint retval = 1;
+ gint retval = 1;
g_autofree gchar *cmd_descriptions = NULL;
const GOptionEntry options[] = {
{ "nonet", '\0', 0, G_OPTION_ARG_NONE, &nonet,
diff --git a/configure.ac b/configure.ac
index c821d95..ad13156 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,6 +96,8 @@ if test "$GCC" = "yes"; then
WARNINGFLAGS_C="$WARNINGFLAGS_C -Wshadow"
WARNINGFLAGS_C="$WARNINGFLAGS_C -Wno-strict-aliasing"
WARNINGFLAGS_C="$WARNINGFLAGS_C -Winline"
+ WARNINGFLAGS_C="$WARNINGFLAGS_C -Wconversion"
+ WARNINGFLAGS_C="$WARNINGFLAGS_C -Wformat-signedness"
else
WARNINGFLAGS_C=""
fi
diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c
index 2a99332..ab32317 100644
--- a/libappstream-builder/asb-context.c
+++ b/libappstream-builder/asb-context.c
@@ -1174,7 +1174,7 @@ asb_context_process (AsbContext *ctx, GError **error)
/* create thread pool */
pool = g_thread_pool_new (asb_task_process_func,
ctx,
- priv->max_threads,
+ (gint) priv->max_threads,
TRUE,
error);
if (pool == NULL)
diff --git a/libappstream-builder/asb-package-alpm.c b/libappstream-builder/asb-package-alpm.c
index f083b0a..f58994e 100644
--- a/libappstream-builder/asb-package-alpm.c
+++ b/libappstream-builder/asb-package-alpm.c
@@ -112,7 +112,7 @@ asb_package_alpm_ensure_version (AsbPackage *pkg, GError **error)
/* epoch:version:release */
if (g_strv_length (split) == 3) {
- asb_package_set_epoch (pkg, g_ascii_strtoll (split[0], NULL, 0));
+ asb_package_set_epoch (pkg, (guint) g_ascii_strtoull (split[0], NULL, 0));
asb_package_set_version (pkg, split[1]);
asb_package_set_release (pkg, split[2]);
} else {/* version:release */
@@ -182,7 +182,7 @@ asb_package_alpm_open (AsbPackage *pkg, const gchar *filename, GError **error)
g_set_error (error,
ASB_PLUGIN_ERROR,
ASB_PLUGIN_ERROR_FAILED,
- "libalpm initialization failed %s (%d) for %s",
+ "libalpm initialization failed %s (%u) for %s",
alpm_strerror (alpm_error),
alpm_error,
filename);
@@ -194,7 +194,7 @@ asb_package_alpm_open (AsbPackage *pkg, const gchar *filename, GError **error)
g_set_error (error,
ASB_PLUGIN_ERROR,
ASB_PLUGIN_ERROR_FAILED,
- "Failed to load package %s : %s (%d)",
+ "Failed to load package %s : %s (%u)",
filename,
alpm_strerror (alpm_errno (priv->handle)),
alpm_errno (priv->handle));
diff --git a/libappstream-builder/asb-package-deb.c b/libappstream-builder/asb-package-deb.c
index 95c1064..6201fd0 100644
--- a/libappstream-builder/asb-package-deb.c
+++ b/libappstream-builder/asb-package-deb.c
@@ -77,7 +77,7 @@ asb_package_deb_ensure_simple (AsbPackage *pkg, GError **error)
asb_package_set_version (pkg, vr[0]);
} else {
*tmp = '\0';
- j = g_ascii_strtoll (vr[0], NULL, 10);
+ j = (guint) g_ascii_strtoull (vr[0], NULL, 10);
asb_package_set_epoch (pkg, j);
asb_package_set_version (pkg, tmp + 1);
}
diff --git a/libappstream-builder/asb-package-rpm.c b/libappstream-builder/asb-package-rpm.c
index 1feb7ea..9c14dd1 100644
--- a/libappstream-builder/asb-package-rpm.c
+++ b/libappstream-builder/asb-package-rpm.c
@@ -149,7 +149,7 @@ asb_package_rpm_ensure_nevra (AsbPackage *pkg, GError **error)
headerGet (priv->h, RPMTAG_ARCH, td, HEADERGET_MINMEM);
asb_package_set_arch (pkg, rpmtdGetString (td));
headerGet (priv->h, RPMTAG_EPOCH, td, HEADERGET_MINMEM);
- asb_package_set_epoch (pkg, rpmtdGetNumber (td));
+ asb_package_set_epoch (pkg, (guint) rpmtdGetNumber (td));
rpmtdFree (td);
return TRUE;
}
@@ -380,7 +380,7 @@ asb_package_rpm_ensure_filelists (AsbPackage *pkg, GError **error)
i = 0;
dirindex = g_new0 (gint32, rpmtdCount (td[2]) + 1);
while (rpmtdNext (td[2]) != -1)
- dirindex[i++] = rpmtdGetNumber (td[2]);
+ dirindex[i++] = (gint32) rpmtdGetNumber (td[2]);
i = 0;
filelist = g_new0 (gchar *, rpmtdCount (td[1]) + 1);
while (rpmtdNext (td[1]) != -1) {
diff --git a/libappstream-builder/asb-package.c b/libappstream-builder/asb-package.c
index a8060d5..8763fd5 100644
--- a/libappstream-builder/asb-package.c
+++ b/libappstream-builder/asb-package.c
@@ -756,7 +756,7 @@ asb_package_get_nevr (AsbPackage *pkg)
priv->version,
priv->release);
} else {
- priv->nevr = g_strdup_printf ("%s-%i:%s-%s",
+ priv->nevr = g_strdup_printf ("%s-%u:%s-%s",
priv->name,
priv->epoch,
priv->version,
@@ -788,7 +788,7 @@ asb_package_get_nevra (AsbPackage *pkg)
priv->release,
priv->arch);
} else {
- priv->nevra = g_strdup_printf ("%s-%i:%s-%s.%s",
+ priv->nevra = g_strdup_printf ("%s-%u:%s-%s.%s",
priv->name,
priv->epoch,
priv->version,
@@ -819,7 +819,7 @@ asb_package_get_evr (AsbPackage *pkg)
priv->version,
priv->release);
} else {
- priv->evr = g_strdup_printf ("%i:%s-%s",
+ priv->evr = g_strdup_printf ("%u:%s-%s",
priv->epoch,
priv->version,
priv->release);
diff --git a/libappstream-builder/asb-package.h b/libappstream-builder/asb-package.h
index 8c2e28f..e63c190 100644
--- a/libappstream-builder/asb-package.h
+++ b/libappstream-builder/asb-package.h
@@ -32,18 +32,16 @@ G_BEGIN_DECLS
#define ASB_TYPE_PACKAGE (asb_package_get_type ())
G_DECLARE_DERIVABLE_TYPE (AsbPackage, asb_package, ASB, PACKAGE, GObject)
-typedef enum {
- ASB_PACKAGE_ENSURE_NONE = 0,
- ASB_PACKAGE_ENSURE_NEVRA = 1,
- ASB_PACKAGE_ENSURE_FILES = 2,
- ASB_PACKAGE_ENSURE_RELEASES = 4,
- ASB_PACKAGE_ENSURE_DEPS = 8,
- ASB_PACKAGE_ENSURE_LICENSE = 16,
- ASB_PACKAGE_ENSURE_URL = 32,
- ASB_PACKAGE_ENSURE_SOURCE = 64,
- ASB_PACKAGE_ENSURE_VCS = 128,
- ASB_PACKAGE_ENSURE_LAST
-} AsbPackageEnsureFlags;
+#define ASB_PACKAGE_ENSURE_NONE (0u)
+#define ASB_PACKAGE_ENSURE_NEVRA (1u << 0)
+#define ASB_PACKAGE_ENSURE_FILES (1u << 1)
+#define ASB_PACKAGE_ENSURE_RELEASES (1u << 2)
+#define ASB_PACKAGE_ENSURE_DEPS (1u << 3)
+#define ASB_PACKAGE_ENSURE_LICENSE (1u << 4)
+#define ASB_PACKAGE_ENSURE_URL (1u << 5)
+#define ASB_PACKAGE_ENSURE_SOURCE (1u << 6)
+#define ASB_PACKAGE_ENSURE_VCS (1u << 7)
+typedef guint64 AsbPackageEnsureFlags;
struct _AsbPackageClass
{
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c
index 8f4fbfb..24674cf 100644
--- a/libappstream-builder/asb-self-test.c
+++ b/libappstream-builder/asb-self-test.c
@@ -142,11 +142,11 @@ asb_test_package_rpm_func (void)
rel = g_ptr_array_index (releases, 0);
g_assert (rel != NULL);
g_assert_cmpstr (as_release_get_version (rel), ==, "0.1");
- g_assert_cmpint (as_release_get_timestamp (rel), ==, 1274097600);
+ g_assert_cmpint ((gint64) as_release_get_timestamp (rel), ==, 1274097600);
g_assert_cmpstr (as_release_get_description (rel, NULL), ==, NULL);
rel = asb_package_get_release (pkg, "0.1");
g_assert (rel != NULL);
- g_assert_cmpint (as_release_get_timestamp (rel), ==, 1274097600);
+ g_assert_cmpint ((gint64) as_release_get_timestamp (rel), ==, 1274097600);
/* check config */
g_assert_cmpstr (asb_package_get_config (pkg, "test"), ==, NULL);
diff --git a/libappstream-builder/asb-task.c b/libappstream-builder/asb-task.c
index 3063d04..3948ff7 100644
--- a/libappstream-builder/asb-task.c
+++ b/libappstream-builder/asb-task.c
@@ -289,7 +289,7 @@ asb_task_process (AsbTask *task, GError **error_not_used)
}
nr_added++;
}
- g_debug ("added %i apps from archive", apps_tmp->len);
+ g_debug ("added %u apps from archive", apps_tmp->len);
goto skip;
}
diff --git a/libappstream-builder/asb-utils.c b/libappstream-builder/asb-utils.c
index 38b123a..c5105d8 100644
--- a/libappstream-builder/asb-utils.c
+++ b/libappstream-builder/asb-utils.c
@@ -468,7 +468,7 @@ asb_utils_add_files_recursive (GPtrArray *files,
dir = g_dir_open (path, 0, error);
if (dir == NULL)
return FALSE;
- path_orig_len = strlen (path_orig);
+ path_orig_len = (guint) strlen (path_orig);
while ((tmp = g_dir_read_name (dir)) != NULL) {
g_autofree gchar *path_new = NULL;
path_new = g_build_filename (path, tmp, NULL);
diff --git a/libappstream-builder/plugins/asb-plugin-font.c b/libappstream-builder/plugins/asb-plugin-font.c
index affd096..972e117 100644
--- a/libappstream-builder/plugins/asb-plugin-font.c
+++ b/libappstream-builder/plugins/asb-plugin-font.c
@@ -321,7 +321,7 @@ asb_font_get_pixbuf (FT_Face ft_face,
/* set up font */
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- width, height);
+ (gint) width, (gint) height);
cr = cairo_create (surface);
font_face = cairo_ft_font_face_create_for_ft_face (ft_face, FT_LOAD_DEFAULT);
cairo_set_font_face (cr, font_face);
@@ -343,7 +343,7 @@ asb_font_get_pixbuf (FT_Face ft_face,
(height / 2) - te.height / 2 - te.y_bearing);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_show_text (cr, text);
- pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
+ pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, (gint) width, (gint) height);
if (pixbuf == NULL) {
g_set_error_literal (error,
ASB_PLUGIN_ERROR,
@@ -514,7 +514,7 @@ asb_font_add_languages (AsbApp *app, const FcPattern *pattern)
FcStrList *list;
FcStrSet *langs;
FcValue fc_value;
- guint i;
+ gint i;
gboolean any_added = FALSE;
gboolean skip_langs;
@@ -544,7 +544,6 @@ asb_plugin_font_set_name (AsbApp *app, const gchar *name)
{
const gchar *ptr;
guint i;
- guint len;
const gchar *prefixes[] = { "GFS ", NULL };
const gchar *suffixes[] = { " SIL",
" ADF",
@@ -558,7 +557,7 @@ asb_plugin_font_set_name (AsbApp *app, const gchar *name)
tmp = g_strdup (name);
for (i = 0; suffixes[i] != NULL; i++) {
if (g_str_has_suffix (tmp, suffixes[i])) {
- len = strlen (tmp);
+ gsize len = strlen (tmp);
tmp[len - strlen (suffixes[i])] = '\0';
}
}
diff --git a/libappstream-builder/plugins/asb-plugin-shell-extension.c b/libappstream-builder/plugins/asb-plugin-shell-extension.c
index b5282ea..f28386a 100644
--- a/libappstream-builder/plugins/asb-plugin-shell-extension.c
+++ b/libappstream-builder/plugins/asb-plugin-shell-extension.c
@@ -66,7 +66,7 @@ as_app_parse_shell_extension_data (AsApp *app,
/* parse the data */
json_parser = json_parser_new ();
- if (!json_parser_load_from_data (json_parser, data, len, error))
+ if (!json_parser_load_from_data (json_parser, data, (gssize) len, error))
return FALSE;
json_root = json_parser_get_root (json_parser);
if (json_root == NULL) {
diff --git a/libappstream-glib/as-app-builder.c b/libappstream-glib/as-app-builder.c
index a63f9c1..e426e04 100644
--- a/libappstream-glib/as-app-builder.c
+++ b/libappstream-glib/as-app-builder.c
@@ -310,7 +310,7 @@ as_app_builder_parse_file_qt (AsAppBuilderContext *ctx,
"file is invalid");
return FALSE;
}
- m += sizeof(qm_magic);
+ m += (guint32) sizeof(qm_magic);
/* parse each section */
while (m < len) {
@@ -479,7 +479,7 @@ as_app_builder_search_translations (AsApp *app,
e = l->data;
if (e->percentage < min_percentage)
continue;
- as_app_add_language (app, e->percentage, e->locale);
+ as_app_add_language (app, (gint) e->percentage, e->locale);
}
return TRUE;
}
diff --git a/libappstream-glib/as-app-validate.c b/libappstream-glib/as-app-validate.c
index d4fb408..57da467 100644
--- a/libappstream-glib/as-app-validate.c
+++ b/libappstream-glib/as-app-validate.c
@@ -95,7 +95,7 @@ ai_app_validate_fullstop_ending (const gchar *tmp)
cnt++;
if (cnt++ > 1)
return FALSE;
- str_len = strlen (tmp);
+ str_len = (guint) strlen (tmp);
if (str_len == 0)
return FALSE;
return tmp[str_len - 1] == '.';
@@ -179,7 +179,7 @@ as_app_validate_description_li (const gchar *text, AsAppValidateHelper *helper)
return;
}
- str_len = strlen (text);
+ str_len = (guint) strlen (text);
if (str_len < length_li_min) {
ai_app_validate_add (helper,
AS_PROBLEM_KIND_STYLE_INCORRECT,
@@ -240,7 +240,7 @@ as_app_validate_description_para (const gchar *text, AsAppValidateHelper *helper
}
helper->previous_para_was_short = FALSE;
- str_len = strlen (text);
+ str_len = (guint) strlen (text);
if (str_len < length_para_min) {
/* we don't add the problem now, as we allow a short
* paragraph as an introduction to a list */
@@ -303,7 +303,7 @@ as_app_validate_description_list (const gchar *text,
helper->para_chars_before_list < (guint) length_para_before_list) {
ai_app_validate_add (helper,
AS_PROBLEM_KIND_STYLE_INCORRECT,
- "Content before <ul> is too short [%d], at least %d characters required",
+ "Content before <ul> is too short [%u], at least %u characters required",
helper->para_chars_before_list,
length_para_before_list);
}
@@ -413,7 +413,7 @@ ai_app_validate_image_check (AsImage *im, AsAppValidateHelper *helper)
gboolean require_correct_aspect_ratio = FALSE;
gdouble desired_aspect = 1.777777778;
gdouble screenshot_aspect;
- gint status_code;
+ guint status_code;
guint screenshot_height;
guint screenshot_width;
guint ss_size_height_max = 900;
@@ -499,8 +499,8 @@ ai_app_validate_image_check (AsImage *im, AsAppValidateHelper *helper)
}
/* check width matches */
- screenshot_width = gdk_pixbuf_get_width (pixbuf);
- screenshot_height = gdk_pixbuf_get_height (pixbuf);
+ screenshot_width = (guint) gdk_pixbuf_get_width (pixbuf);
+ screenshot_height = (guint) gdk_pixbuf_get_height (pixbuf);
if (as_image_get_width (im) != 0 &&
as_image_get_width (im) != screenshot_width) {
ai_app_validate_add (helper,
@@ -585,7 +585,7 @@ as_app_validate_image (AsImage *im, AsAppValidateHelper *helper)
/* blank */
url = as_image_get_url (im);
- if (strlen (url) == 0) {
+ if ((guint) strlen (url) == 0) {
ai_app_validate_add (helper,
AS_PROBLEM_KIND_VALUE_MISSING,
"<screenshot> has no content");
@@ -638,7 +638,7 @@ as_app_validate_screenshot (AsScreenshot *ss, AsAppValidateHelper *helper)
}
tmp = as_screenshot_get_caption (ss, NULL);
if (tmp != NULL) {
- str_len = strlen (tmp);
+ str_len = (guint) strlen (tmp);
if (str_len < length_caption_min) {
ai_app_validate_add (helper,
AS_PROBLEM_KIND_STYLE_INCORRECT,
@@ -1340,7 +1340,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error)
/* name */
name = as_app_get_name (app, "C");
if (name != NULL) {
- str_len = strlen (name);
+ str_len = (guint) strlen (name);
if (str_len < length_name_min) {
ai_app_validate_add (&helper,
AS_PROBLEM_KIND_STYLE_INCORRECT,
@@ -1379,7 +1379,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error)
/* comment */
summary = as_app_get_comment (app, "C");
if (summary != NULL) {
- str_len = strlen (summary);
+ str_len = (guint) strlen (summary);
if (str_len < length_summary_min) {
ai_app_validate_add (&helper,
AS_PROBLEM_KIND_STYLE_INCORRECT,
@@ -1464,7 +1464,7 @@ as_app_validate (AsApp *app, AsAppValidateFlags flags, GError **error)
/* developer_name */
name = as_app_get_developer_name (app, NULL);
if (name != NULL) {
- str_len = strlen (name);
+ str_len = (guint) strlen (name);
if (str_len < length_name_min) {
ai_app_validate_add (&helper,
AS_PROBLEM_KIND_STYLE_INCORRECT,
diff --git a/libappstream-glib/as-app.c b/libappstream-glib/as-app.c
index dbb4f91..e4d6531 100644
--- a/libappstream-glib/as-app.c
+++ b/libappstream-glib/as-app.c
@@ -106,19 +106,17 @@ G_DEFINE_TYPE_WITH_PRIVATE (AsApp, as_app, G_TYPE_OBJECT)
#define GET_PRIVATE(o) (as_app_get_instance_private (o))
-
-typedef enum {
- AS_APP_TOKEN_MATCH_NONE = 0, /* 0x00 */
- AS_APP_TOKEN_MATCH_MIMETYPE = 1 << 0, /* 0x01 */
- AS_APP_TOKEN_MATCH_PKGNAME = 1 << 1, /* 0x02 */
- AS_APP_TOKEN_MATCH_DESCRIPTION = 1 << 2, /* 0x04 */
- AS_APP_TOKEN_MATCH_COMMENT = 1 << 3, /* 0x08 */
- AS_APP_TOKEN_MATCH_NAME = 1 << 4, /* 0x10 */
- AS_APP_TOKEN_MATCH_KEYWORD = 1 << 5, /* 0x20 */
- AS_APP_TOKEN_MATCH_ID = 1 << 6, /* 0x40 */
- AS_APP_TOKEN_MATCH_LAST
-} AsAppTokenMatch;
-
+#define AS_APP_TOKEN_MATCH_NONE (0u) /* 0x00 */
+#define AS_APP_TOKEN_MATCH_MIMETYPE (1u << 0) /* 0x01 */
+#define AS_APP_TOKEN_MATCH_PKGNAME (1u << 1) /* 0x02 */
+#define AS_APP_TOKEN_MATCH_DESCRIPTION (1u << 2) /* 0x04 */
+#define AS_APP_TOKEN_MATCH_COMMENT (1u << 3) /* 0x08 */
+#define AS_APP_TOKEN_MATCH_NAME (1u << 4) /* 0x10 */
+#define AS_APP_TOKEN_MATCH_KEYWORD (1u << 5) /* 0x20 */
+#define AS_APP_TOKEN_MATCH_ID (1u << 6) /* 0x40 */
+#define AS_APP_TOKEN_MATCH_LAST
+
+typedef guint16 AsAppTokenMatch;
typedef guint16 AsAppTokenType; /* big enough for both bitshifts */
/**
@@ -1958,7 +1956,7 @@ as_app_set_update_contact (AsApp *app, const gchar *update_contact)
return;
/* keep going until we have no more matches */
- len = strlen (priv->update_contact);
+ len = (guint) strlen (priv->update_contact);
while (done_replacement) {
done_replacement = FALSE;
for (i = 0; replacements[i].search != NULL; i++) {
@@ -3624,9 +3622,11 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags,
/* <priority> */
case AS_TAG_PRIORITY:
- as_app_set_priority (app, g_ascii_strtoll (as_node_get_data (n),
- NULL, 10));
+ {
+ gint64 tmp64 = g_ascii_strtoll (as_node_get_data (n), NULL, 10);
+ as_app_set_priority (app, (gint) tmp64);
break;
+ }
/* <pkgname> */
case AS_TAG_PKGNAME:
@@ -3967,7 +3967,7 @@ as_app_node_parse_child (AsApp *app, GNode *n, AsAppParseFlags flags,
if (!(flags & AS_APP_PARSE_FLAG_APPEND_DATA))
g_hash_table_remove_all (priv->languages);
for (c = n->children; c != NULL; c = c->next) {
- guint percent;
+ gint percent;
if (as_node_get_tag (c) != AS_TAG_LANG)
continue;
percent = as_node_get_attribute_as_int (c, "percentage");
@@ -4033,7 +4033,7 @@ as_app_node_parse_full (AsApp *app, GNode *node, AsAppParseFlags flags,
AsAppPrivate *priv = GET_PRIVATE (app);
GNode *n;
const gchar *tmp;
- guint prio;
+ gint prio;
/* new style */
if (g_strcmp0 (as_node_get_name (node), "component") == 0) {
@@ -4564,7 +4564,7 @@ as_app_search_matches (AsApp *app, const gchar *search)
search_stem = as_stemmer_process (priv->stemmer, search);
match_pval = g_hash_table_lookup (priv->token_cache, search_stem);
if (match_pval != NULL)
- return *match_pval << 2;
+ return (guint) *match_pval << 2;
/* need to do partial match */
keys = g_hash_table_get_keys (priv->token_cache);
@@ -4757,7 +4757,7 @@ as_app_parse_appdata_file (AsApp *app,
}
/* validate */
- tmp = g_strstr_len (data, len, "<?xml version=");
+ tmp = g_strstr_len (data, (gssize) len, "<?xml version=");
if (tmp == NULL)
priv->problems |= AS_APP_PROBLEM_NO_XML_HEADER;
diff --git a/libappstream-glib/as-icon.c b/libappstream-glib/as-icon.c
index bceaf78..1d03638 100644
--- a/libappstream-glib/as-icon.c
+++ b/libappstream-glib/as-icon.c
@@ -438,8 +438,8 @@ as_icon_set_pixbuf (AsIcon *icon, GdkPixbuf *pixbuf)
AsIconPrivate *priv = GET_PRIVATE (icon);
g_set_object (&priv->pixbuf, pixbuf);
if (pixbuf != NULL) {
- priv->width = gdk_pixbuf_get_width (pixbuf);
- priv->height = gdk_pixbuf_get_height (pixbuf);
+ priv->width = (guint) gdk_pixbuf_get_width (pixbuf);
+ priv->height = (guint) gdk_pixbuf_get_height (pixbuf);
}
}
@@ -478,8 +478,8 @@ as_icon_node_insert_embedded (AsIcon *icon, GNode *parent, AsNodeContext *ctx)
"type", as_icon_kind_to_string (priv->kind),
NULL);
if (as_node_context_get_version (ctx) >= 0.8) {
- as_node_add_attribute_as_int (n, "width", priv->width);
- as_node_add_attribute_as_int (n, "height", priv->height);
+ as_node_add_attribute_as_uint (n, "width", priv->width);
+ as_node_add_attribute_as_uint (n, "height", priv->height);
}
as_node_insert (n, "name", priv->name, 0, NULL);
data = g_base64_encode (g_bytes_get_data (priv->data, NULL),
@@ -538,9 +538,9 @@ as_icon_node_insert (AsIcon *icon, GNode *parent, AsNodeContext *ctx)
if (priv->kind == AS_ICON_KIND_CACHED &&
as_node_context_get_version (ctx) >= 0.8) {
if (priv->width > 0)
- as_node_add_attribute_as_int (n, "width", priv->width);
+ as_node_add_attribute_as_uint (n, "width", priv->width);
if (priv->height > 0)
- as_node_add_attribute_as_int (n, "height", priv->height);
+ as_node_add_attribute_as_uint (n, "height", priv->height);
}
return n;
}
@@ -619,7 +619,7 @@ as_icon_node_parse (AsIcon *icon, GNode *node,
{
AsIconPrivate *priv = GET_PRIVATE (icon);
const gchar *tmp;
- gint size;
+ guint size;
gboolean prepend_size = TRUE;
tmp = as_node_get_attribute (node, "type");
@@ -656,16 +656,16 @@ as_icon_node_parse (AsIcon *icon, GNode *node,
}
/* width is optional, assume 64px if missing */
- size = as_node_get_attribute_as_int (node, "width");
- if (size == G_MAXINT) {
+ size = as_node_get_attribute_as_uint (node, "width");
+ if (size == G_MAXUINT) {
size = 64;
prepend_size = FALSE;
}
priv->width = size;
/* height is optional, assume 64px if missing */
- size = as_node_get_attribute_as_int (node, "height");
- if (size == G_MAXINT) {
+ size = as_node_get_attribute_as_uint (node, "height");
+ if (size == G_MAXUINT) {
size = 64;
prepend_size = FALSE;
}
@@ -674,7 +674,7 @@ as_icon_node_parse (AsIcon *icon, GNode *node,
/* only use the size if the metadata has width and height */
if (prepend_size) {
g_free (priv->prefix_private);
- priv->prefix_private = g_strdup_printf ("%s/%ix%i",
+ priv->prefix_private = g_strdup_printf ("%s/%ux%u",
priv->prefix,
priv->width,
priv->height);
@@ -707,17 +707,17 @@ as_icon_node_parse_dep11 (AsIcon *icon, GNode *node,
for (n = node->children; n != NULL; n = n->next) {
const gchar *key;
- gint size;
+ guint size;
key = as_yaml_node_get_key (n);
if (g_strcmp0 (key, "width") == 0) {
- size = as_yaml_node_get_value_as_int (n);
- if (size == G_MAXINT)
+ size = as_yaml_node_get_value_as_uint (n);
+ if (size == G_MAXUINT)
size = 64;
priv->width = size;
} else if (g_strcmp0 (key, "height") == 0) {
- size = as_yaml_node_get_value_as_int (n);
- if (size == G_MAXINT)
+ size = as_yaml_node_get_value_as_uint (n);
+ if (size == G_MAXUINT)
size = 64;
priv->height = size;
} else {
@@ -784,8 +784,8 @@ as_icon_load (AsIcon *icon, AsIconLoadFlags flags, GError **error)
return FALSE;
}
pixbuf = gdk_pixbuf_new_from_file_at_size (priv->filename,
- priv->width,
- priv->height,
+ (gint) priv->width,
+ (gint) priv->height,
error);
if (pixbuf == NULL)
return FALSE;
@@ -811,7 +811,7 @@ as_icon_load (AsIcon *icon, AsIconLoadFlags flags, GError **error)
for (i = 0; widths[i] != 0; i++) {
g_autofree gchar *fn_size = NULL;
g_autofree gchar *size_str = NULL;
- size_str = g_strdup_printf ("%ix%i", widths[i], height[i]);
+ size_str = g_strdup_printf ("%ux%u", widths[i], height[i]);
fn_size = g_build_filename (priv->prefix, size_str, priv->name, NULL);
if (g_file_test (fn_size, G_FILE_TEST_EXISTS)) {
pixbuf = gdk_pixbuf_new_from_file (fn_size, error);
@@ -887,7 +887,7 @@ as_icon_convert_to_kind (AsIcon *icon, AsIconKind kind, GError **error)
g_autofree gchar *fn = NULL;
/* ensure the parent path exists */
- size_str = g_strdup_printf ("%ix%i", priv->width, priv->height);
+ size_str = g_strdup_printf ("%ux%u", priv->width, priv->height);
path = g_build_filename (priv->prefix, size_str, NULL);
if (g_mkdir_with_parents (path, 0700) != 0) {
g_set_error (error,
diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c
index dff68f7..3cf060f 100644
--- a/libappstream-glib/as-image.c
+++ b/libappstream-glib/as-image.c
@@ -383,8 +383,8 @@ as_image_set_pixbuf (AsImage *image, GdkPixbuf *pixbuf)
priv->md5 = g_compute_checksum_for_data (G_CHECKSUM_MD5,
data, len);
}
- priv->width = gdk_pixbuf_get_width (pixbuf);
- priv->height = gdk_pixbuf_get_height (pixbuf);
+ priv->width = (guint) gdk_pixbuf_get_width (pixbuf);
+ priv->height = (guint) gdk_pixbuf_get_height (pixbuf);
}
/**
@@ -404,24 +404,15 @@ as_image_node_insert (AsImage *image, GNode *parent, AsNodeContext *ctx)
{
AsImagePrivate *priv = GET_PRIVATE (image);
GNode *n;
- gchar tmp_height[6];
- gchar tmp_width[6];
-
- if (priv->width > 0 && priv->height > 0) {
- g_snprintf (tmp_width, sizeof (tmp_width), "%u", priv->width);
- g_snprintf (tmp_height, sizeof (tmp_height), "%u", priv->height);
- n = as_node_insert (parent, "image", priv->url,
- AS_NODE_INSERT_FLAG_NONE,
- "width", tmp_width,
- "height", tmp_height,
- "type", as_image_kind_to_string (priv->kind),
- NULL);
- } else {
- n = as_node_insert (parent, "image", priv->url,
- AS_NODE_INSERT_FLAG_NONE,
- "type", as_image_kind_to_string (priv->kind),
- NULL);
- }
+ n = as_node_insert (parent, "image", priv->url,
+ AS_NODE_INSERT_FLAG_NONE,
+ NULL);
+ if (priv->width > 0)
+ as_node_add_attribute_as_uint (n, "width", priv->width);
+ if (priv->height > 0)
+ as_node_add_attribute_as_uint (n, "height", priv->height);
+ if (priv->kind > AS_IMAGE_KIND_UNKNOWN)
+ as_node_add_attribute (n, "type", as_image_kind_to_string (priv->kind));
if (priv->locale != NULL)
as_node_add_attribute (n, "xml:lang", priv->locale);
return n;
@@ -449,11 +440,11 @@ as_image_node_parse (AsImage *image, GNode *node,
gchar *taken;
guint size;
- size = as_node_get_attribute_as_int (node, "width");
- if (size != G_MAXINT)
+ size = as_node_get_attribute_as_uint (node, "width");
+ if (size != G_MAXUINT)
as_image_set_width (image, size);
- size = as_node_get_attribute_as_int (node, "height");
- if (size != G_MAXINT)
+ size = as_node_get_attribute_as_uint (node, "height");
+ if (size != G_MAXUINT)
as_image_set_height (image, size);
tmp = as_node_get_attribute (node, "type");
if (tmp == NULL)
@@ -496,9 +487,9 @@ as_image_node_parse_dep11 (AsImage *im, GNode *node,
for (n = node->children; n != NULL; n = n->next) {
tmp = as_yaml_node_get_key (n);
if (g_strcmp0 (tmp, "height") == 0)
- as_image_set_height (im, as_yaml_node_get_value_as_int (n));
+ as_image_set_height (im, as_yaml_node_get_value_as_uint (n));
else if (g_strcmp0 (tmp, "width") == 0)
- as_image_set_width (im, as_yaml_node_get_value_as_int (n));
+ as_image_set_width (im, as_yaml_node_get_value_as_uint (n));
else if (g_strcmp0 (tmp, "url") == 0) {
const gchar *media_base_url = as_node_context_get_media_base_url (ctx);
if (media_base_url != NULL) {
@@ -601,8 +592,8 @@ as_image_load_filename_full (AsImage *image,
/* open file in native size */
if (g_str_has_suffix (filename, ".svg")) {
pixbuf_src = gdk_pixbuf_new_from_file_at_scale (filename,
- dest_size,
- dest_size,
+ (gint) dest_size,
+ (gint) dest_size,
TRUE, error);
} else {
pixbuf_src = gdk_pixbuf_new_from_file (filename, error);
@@ -623,8 +614,8 @@ as_image_load_filename_full (AsImage *image,
}
/* don't do anything to an icon with the perfect size */
- pixbuf_width = gdk_pixbuf_get_width (pixbuf_src);
- pixbuf_height = gdk_pixbuf_get_height (pixbuf_src);
+ pixbuf_width = (guint) gdk_pixbuf_get_width (pixbuf_src);
+ pixbuf_height = (guint) gdk_pixbuf_get_height (pixbuf_src);
if (pixbuf_width == dest_size && pixbuf_height == dest_size) {
as_image_set_pixbuf (image, pixbuf_src);
return TRUE;
@@ -632,18 +623,19 @@ as_image_load_filename_full (AsImage *image,
/* never scale up, just pad */
if (pixbuf_width < dest_size && pixbuf_height < dest_size) {
- g_debug ("icon padded to %ix%i as size %ix%i",
+ g_debug ("icon padded to %ux%u as size %ux%u",
dest_size, dest_size,
pixbuf_width, pixbuf_height);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
- dest_size, dest_size);
+ (gint) dest_size, (gint) dest_size);
gdk_pixbuf_fill (pixbuf, 0x00000000);
gdk_pixbuf_copy_area (pixbuf_src,
0, 0, /* of src */
- pixbuf_width, pixbuf_height,
+ (gint) pixbuf_width,
+ (gint) pixbuf_height,
pixbuf,
- (dest_size - pixbuf_width) / 2,
- (dest_size - pixbuf_height) / 2);
+ (gint) (dest_size - pixbuf_width) / 2,
+ (gint) (dest_size - pixbuf_height) / 2);
as_image_set_pixbuf (image, pixbuf);
return TRUE;
}
@@ -651,7 +643,8 @@ as_image_load_filename_full (AsImage *image,
/* is the aspect ratio perfectly square */
if (pixbuf_width == pixbuf_height) {
pixbuf = gdk_pixbuf_scale_simple (pixbuf_src,
- dest_size, dest_size,
+ (gint) dest_size,
+ (gint) dest_size,
GDK_INTERP_HYPER);
as_image_set_pixbuf (image, pixbuf);
return TRUE;
@@ -659,7 +652,7 @@ as_image_load_filename_full (AsImage *image,
/* create new square pixbuf with alpha padding */
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
- dest_size, dest_size);
+ (gint) dest_size, (gint) dest_size);
gdk_pixbuf_fill (pixbuf, 0x00000000);
if (pixbuf_width > pixbuf_height) {
tmp_width = dest_size;
@@ -668,16 +661,18 @@ as_image_load_filename_full (AsImage *image,
tmp_width = dest_size * pixbuf_width / pixbuf_height;
tmp_height = dest_size;
}
- pixbuf_tmp = gdk_pixbuf_scale_simple (pixbuf_src, tmp_width, tmp_height,
+ pixbuf_tmp = gdk_pixbuf_scale_simple (pixbuf_src,
+ (gint) tmp_width,
+ (gint) tmp_height,
GDK_INTERP_HYPER);
if (flags & AS_IMAGE_LOAD_FLAG_SHARPEN)
as_pixbuf_sharpen (pixbuf_tmp, 1, -0.5);
gdk_pixbuf_copy_area (pixbuf_tmp,
0, 0, /* of src */
- tmp_width, tmp_height,
+ (gint) tmp_width, (gint) tmp_height,
pixbuf,
- (dest_size - tmp_width) / 2,
- (dest_size - tmp_height) / 2);
+ (gint) (dest_size - tmp_width) / 2,
+ (gint) (dest_size - tmp_height) / 2);
as_image_set_pixbuf (image, pixbuf);
return TRUE;
}
@@ -743,13 +738,13 @@ as_image_save_pixbuf (AsImage *image,
/* 0 means 'default' */
if (width == 0)
- width = gdk_pixbuf_get_width (priv->pixbuf);
+ width = (guint) gdk_pixbuf_get_width (priv->pixbuf);
if (height == 0)
- height = gdk_pixbuf_get_height (priv->pixbuf);
+ height = (guint) gdk_pixbuf_get_height (priv->pixbuf);
/* don't do anything to an image with the correct size */
- pixbuf_width = gdk_pixbuf_get_width (priv->pixbuf);
- pixbuf_height = gdk_pixbuf_get_height (priv->pixbuf);
+ pixbuf_width = (guint) gdk_pixbuf_get_width (priv->pixbuf);
+ pixbuf_height = (guint) gdk_pixbuf_get_height (priv->pixbuf);
if (width == pixbuf_width && height == pixbuf_height)
return g_object_ref (priv->pixbuf);
@@ -757,7 +752,7 @@ as_image_save_pixbuf (AsImage *image,
if (flags == AS_IMAGE_SAVE_FLAG_NONE ||
(pixbuf_width / 16) * 9 == pixbuf_height) {
pixbuf = gdk_pixbuf_scale_simple (priv->pixbuf,
- width, height,
+ (gint) width, (gint) height,
GDK_INTERP_HYPER);
if ((flags & AS_IMAGE_SAVE_FLAG_SHARPEN) > 0)
as_pixbuf_sharpen (pixbuf, 1, -0.5);
@@ -769,8 +764,8 @@ as_image_save_pixbuf (AsImage *image,
/* create new 16:9 pixbuf with alpha padding */
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
TRUE, 8,
- width,
- height);
+ (gint) width,
+ (gint) height);
gdk_pixbuf_fill (pixbuf, 0x00000000);
if ((pixbuf_width / 16) * 9 > pixbuf_height) {
tmp_width = width;
@@ -780,7 +775,8 @@ as_image_save_pixbuf (AsImage *image,
tmp_height = height;
}
pixbuf_tmp = gdk_pixbuf_scale_simple (priv->pixbuf,
- tmp_width, tmp_height,
+ (gint) tmp_width,
+ (gint) tmp_height,
GDK_INTERP_HYPER);
if ((flags & AS_IMAGE_SAVE_FLAG_SHARPEN) > 0)
as_pixbuf_sharpen (pixbuf_tmp, 1, -0.5);
@@ -788,10 +784,11 @@ as_image_save_pixbuf (AsImage *image,
as_pixbuf_blur (pixbuf_tmp, 5, 3);
gdk_pixbuf_copy_area (pixbuf_tmp,
0, 0, /* of src */
- tmp_width, tmp_height,
+ (gint) tmp_width,
+ (gint) tmp_height,
pixbuf,
- (width - tmp_width) / 2,
- (height - tmp_height) / 2);
+ (gint) (width - tmp_width) / 2,
+ (gint) (height - tmp_height) / 2);
return pixbuf;
}
@@ -832,11 +829,11 @@ as_image_save_filename (AsImage *image,
static gboolean
is_pixel_alpha (GdkPixbuf *pixbuf, guint x, guint y)
{
- gint rowstride, n_channels;
+ guint rowstride, n_channels;
guchar *pixels, *p;
- n_channels = gdk_pixbuf_get_n_channels (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ n_channels = (guint) gdk_pixbuf_get_n_channels (pixbuf);
+ rowstride = (guint) gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
p = pixels + y * rowstride + x * n_channels;
@@ -879,16 +876,16 @@ as_image_get_alpha_flags (AsImage *image)
AsImagePrivate *priv = GET_PRIVATE (image);
gboolean complete_line_of_alpha;
gboolean is_alpha;
- gint width, height;
- gint x, y;
+ guint width, height;
+ guint x, y;
guint cnt_content_to_alpha_h;
guint cnt_content_to_alpha_v = 0;
if (!gdk_pixbuf_get_has_alpha (priv->pixbuf))
return AS_IMAGE_ALPHA_FLAG_NONE;
- width = gdk_pixbuf_get_width (priv->pixbuf);
- height = gdk_pixbuf_get_height (priv->pixbuf);
+ width = (guint) gdk_pixbuf_get_width (priv->pixbuf);
+ height = (guint) gdk_pixbuf_get_height (priv->pixbuf);
for (y = 0; y < height; y++) {
mode_h = AS_IMAGE_ALPHA_MODE_START;
complete_line_of_alpha = TRUE;
diff --git a/libappstream-glib/as-image.h b/libappstream-glib/as-image.h
index c0d829c..2ec046f 100644
--- a/libappstream-glib/as-image.h
+++ b/libappstream-glib/as-image.h
@@ -113,16 +113,13 @@ typedef enum {
*
* The flags used for reporting the alpha cutouts in the image.
**/
-typedef enum {
- AS_IMAGE_ALPHA_FLAG_NONE = 0, /* Since: 0.2.2 */
- AS_IMAGE_ALPHA_FLAG_TOP = 1, /* Since: 0.2.2 */
- AS_IMAGE_ALPHA_FLAG_BOTTOM = 2, /* Since: 0.2.2 */
- AS_IMAGE_ALPHA_FLAG_LEFT = 4, /* Since: 0.2.2 */
- AS_IMAGE_ALPHA_FLAG_RIGHT = 8, /* Since: 0.2.2 */
- AS_IMAGE_ALPHA_FLAG_INTERNAL = 16, /* Since: 0.2.2 */
- /*< private >*/
- AS_IMAGE_ALPHA_FLAG_LAST
-} AsImageAlphaFlags;
+#define AS_IMAGE_ALPHA_FLAG_NONE (0u) /* Since: 0.2.2 */
+#define AS_IMAGE_ALPHA_FLAG_TOP (1u << 0) /* Since: 0.2.2 */
+#define AS_IMAGE_ALPHA_FLAG_BOTTOM (1u << 1) /* Since: 0.2.2 */
+#define AS_IMAGE_ALPHA_FLAG_LEFT (1u << 2) /* Since: 0.2.2 */
+#define AS_IMAGE_ALPHA_FLAG_RIGHT (1u << 3) /* Since: 0.2.2 */
+#define AS_IMAGE_ALPHA_FLAG_INTERNAL (1u << 4) /* Since: 0.2.2 */
+typedef guint AsImageAlphaFlags;
/* some useful constants */
#define AS_IMAGE_LARGE_HEIGHT 423 /* Since: 0.2.2 */
diff --git a/libappstream-glib/as-inf.c b/libappstream-glib/as-inf.c
index d1523e9..067748d 100644
--- a/libappstream-glib/as-inf.c
+++ b/libappstream-glib/as-inf.c
@@ -515,7 +515,7 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error)
}
/* last char continuation */
- len = strlen (line);
+ len = (guint) strlen (line);
if (line[len-1] == '\\') {
line[len-1] = '\0';
continuation = TRUE;
@@ -695,7 +695,7 @@ as_inf_parse_line (AsInfHelper *helper, gchar *line, GError **error)
}
/* add fake key */
- key = g_strdup_printf ("value%03i", helper->nokey_idx++);
+ key = g_strdup_printf ("value%03u", helper->nokey_idx++);
as_inf_set_key (helper, key, line);
out:
helper->last_line_continuation = continuation;
@@ -760,7 +760,7 @@ as_inf_load_data (GKeyFile *keyfile,
for (i = 0; lines[i] != NULL; i++) {
if (!as_inf_parse_line (helper, lines[i], error)) {
g_prefix_error (error,
- "Failed to parse line %i: ",
+ "Failed to parse line %u: ",
i + 1);
ret = FALSE;
goto out;
@@ -781,7 +781,7 @@ as_inf_load_data (GKeyFile *keyfile,
for (i = 0; lines2[i] != NULL; i++) {
if (!as_inf_parse_line (helper, lines2[i], error)) {
g_prefix_error (error,
- "Failed to parse line %i: ",
+ "Failed to parse line %u: ",
i + 1);
ret = FALSE;
goto out;
@@ -928,7 +928,7 @@ as_inf_get_driver_version (GKeyFile *keyfile, guint64 *timestamp, GError **error
dv_split[0]);
return NULL;
}
- *timestamp = g_date_time_to_unix (dt);
+ *timestamp = (guint64) g_date_time_to_unix (dt);
}
return g_strdup (dv_split[1]);
}
diff --git a/libappstream-glib/as-markup.c b/libappstream-glib/as-markup.c
index 8870131..5241e68 100644
--- a/libappstream-glib/as-markup.c
+++ b/libappstream-glib/as-markup.c
@@ -193,8 +193,8 @@ static void
as_markup_import_html_erase (GString *str, const gchar *start, const gchar *end)
{
guint i, j;
- guint start_len = strlen (start);
- guint end_len = strlen (end);
+ guint start_len = (guint) strlen (start);
+ guint end_len = (guint) strlen (end);
for (i = 0; str->str[i] != '\0'; i++) {
if (memcmp (&str->str[i], start, start_len) != 0)
continue;
@@ -203,7 +203,7 @@ as_markup_import_html_erase (GString *str, const gchar *start, const gchar *end)
continue;
/* delete this section and restart the search */
g_string_erase (str, i, (j - i) + end_len);
- i = -1;
+ i = (guint) -1;
break;
}
}
diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c
index 8040527..2e771d1 100644
--- a/libappstream-glib/as-node.c
+++ b/libappstream-glib/as-node.c
@@ -169,9 +169,9 @@ as_node_string_replace_inplace (gchar *text,
while ((tmp = g_strstr_len (start, -1, search)) != NULL) {
*tmp = replace;
- len = strlen (tmp);
+ len = (guint) strlen (tmp);
if (len_escaped == 0)
- len_escaped = strlen (search);
+ len_escaped = (guint) strlen (search);
memcpy (tmp + 1,
tmp + len_escaped,
(len - len_escaped) + 1);
@@ -388,7 +388,7 @@ as_node_reflow_text (const gchar *text, gssize text_len)
g_auto(GStrv) split = NULL;
/* split the text into lines */
- tmp = g_string_sized_new (text_len + 1);
+ tmp = g_string_sized_new ((gsize) text_len + 1);
split = g_strsplit (text, "\n", -1);
for (i = 0; split[i] != NULL; i++) {
@@ -544,7 +544,7 @@ as_node_text_cb (GMarkupParseContext *context,
if ((helper->flags & AS_NODE_FROM_XML_FLAG_LITERAL_TEXT) > 0) {
data->cdata = g_strndup (text, text_len);
} else {
- data->cdata = as_node_reflow_text (text, text_len);
+ data->cdata = as_node_reflow_text (text, (gssize) text_len);
}
}
@@ -566,7 +566,9 @@ as_node_passthrough_cb (GMarkupParseContext *context,
return;
/* xml header */
- if (g_strstr_len (passthrough_text, passthrough_len, "<?xml") != NULL)
+ if (g_strstr_len (passthrough_text,
+ (gssize) passthrough_len,
+ "<?xml") != NULL)
return;
/* get stripped comment without '<!--' and '-->' */
@@ -1051,7 +1053,36 @@ as_node_get_attribute_as_int (const AsNode *node, const gchar *key)
return G_MAXINT;
if (value_tmp > G_MAXINT || value_tmp < G_MININT)
return G_MAXINT;
- return value_tmp;
+ return (gint) value_tmp;
+}
+
+/**
+ * as_node_get_attribute_as_uint:
+ * @node: a #AsNode
+ * @key: the attribute key
+ *
+ * Gets a node attribute, e.g. 34
+ *
+ * Return value: integer value, or %G_MAXINT for error
+ *
+ * Since: 0.5.18
+ **/
+guint
+as_node_get_attribute_as_uint (const AsNode *node, const gchar *key)
+{
+ const gchar *tmp;
+ gchar *endptr = NULL;
+ guint64 value_tmp;
+
+ tmp = as_node_get_attribute (node, key);
+ if (tmp == NULL)
+ return G_MAXUINT;
+ value_tmp = g_ascii_strtoull (tmp, &endptr, 10);
+ if (value_tmp == 0 && tmp == endptr)
+ return G_MAXUINT;
+ if (value_tmp > G_MAXUINT)
+ return G_MAXUINT;
+ return (guint) value_tmp;
}
/**
@@ -1185,6 +1216,23 @@ as_node_add_attribute_as_int (AsNode *node, const gchar *key, gint value)
}
/**
+ * as_node_add_attribute_as_uint: (skip)
+ * @node: a #AsNode
+ * @key: the attribute key
+ * @value: new data
+ *
+ * Adds a new attribute to a node.
+ *
+ * Since: 0.5.18
+ **/
+void
+as_node_add_attribute_as_uint (AsNode *node, const gchar *key, guint value)
+{
+ g_autofree gchar *tmp = g_strdup_printf ("%u", value);
+ as_node_add_attribute (node, key, tmp);
+}
+
+/**
* as_node_find: (skip)
* @root: a root node, or %NULL
* @path: a path in the DOM, e.g. "html/body"
@@ -1261,7 +1309,7 @@ as_node_insert_line_breaks (const gchar *text, guint break_len)
guint new_len;
/* allocate long enough for the string, plus the extra newlines */
- new_len = strlen (text) * (break_len + 1) / break_len;
+ new_len = (guint) strlen (text) * (break_len + 1) / break_len;
str = g_string_new_len (NULL, new_len + 2);
g_string_append (str, "\n");
g_string_append (str, text);
diff --git a/libappstream-glib/as-node.h b/libappstream-glib/as-node.h
index a5d7fc3..d18c924 100644
--- a/libappstream-glib/as-node.h
+++ b/libappstream-glib/as-node.h
@@ -128,6 +128,8 @@ const gchar *as_node_get_attribute (const GNode *node,
const gchar *key);
gint as_node_get_attribute_as_int (const GNode *node,
const gchar *key);
+guint as_node_get_attribute_as_uint (const GNode *node,
+ const gchar *key);
GHashTable *as_node_get_localized (const GNode *node,
const gchar *key);
const gchar *as_node_get_localized_best (const GNode *node,
@@ -148,6 +150,9 @@ void as_node_add_attribute (GNode *node,
void as_node_add_attribute_as_int (GNode *node,
const gchar *key,
gint value);
+void as_node_add_attribute_as_uint (GNode *node,
+ const gchar *key,
+ guint value);
void as_node_remove_attribute (GNode *node,
const gchar *key);
diff --git a/libappstream-glib/as-profile.c b/libappstream-glib/as-profile.c
index c6833db..7391c35 100644
--- a/libappstream-glib/as-profile.c
+++ b/libappstream-glib/as-profile.c
@@ -178,7 +178,7 @@ as_profile_task_free_internal (AsProfile *profile, const gchar *id)
}
/* debug */
- elapsed_ms = (item->time_stop - item->time_start) / 1000;
+ elapsed_ms = (gdouble) (item->time_stop - item->time_start) / 1000;
if (elapsed_ms > 5)
g_debug ("%s took %.0fms", id_thr, elapsed_ms);
@@ -285,10 +285,11 @@ as_profile_dump (AsProfile *profile)
continue;
/* print a timechart of what we've done */
- bar_offset = scale * (item->time_start - time_start) / 1000;
+ bar_offset = (guint) (scale * (gdouble) (item->time_start -
+ time_start) / 1000);
for (j = 0; j < bar_offset; j++)
g_print (" ");
- bar_length = scale * time_ms;
+ bar_length = (guint) (scale * (gdouble) time_ms);
if (bar_length == 0)
bar_length = 1;
for (j = 0; j < bar_length; j++)
diff --git a/libappstream-glib/as-release.c b/libappstream-glib/as-release.c
index b273078..a0fda4a 100644
--- a/libappstream-glib/as-release.c
+++ b/libappstream-glib/as-release.c
@@ -626,13 +626,13 @@ as_release_node_parse (AsRelease *release, GNode *node,
tmp = as_node_get_attribute (node, "timestamp");
if (tmp != NULL)
- as_release_set_timestamp (release, atol (tmp));
+ as_release_set_timestamp (release, g_ascii_strtoull (tmp, NULL, 10));
tmp = as_node_get_attribute (node, "date");
if (tmp != NULL) {
g_autoptr(GDateTime) dt = NULL;
dt = as_utils_iso8601_to_datetime (tmp);
if (dt != NULL)
- as_release_set_timestamp (release, g_date_time_to_unix (dt));
+ as_release_set_timestamp (release, (guint64) g_date_time_to_unix (dt));
}
tmp = as_node_get_attribute (node, "urgency");
if (tmp != NULL)
@@ -735,7 +735,7 @@ as_release_node_parse_dep11 (AsRelease *release, GNode *node,
tmp = as_yaml_node_get_key (n);
if (g_strcmp0 (tmp, "unix-timestamp") == 0) {
value = as_yaml_node_get_value (n);
- as_release_set_timestamp (release, atol (value));
+ as_release_set_timestamp (release, g_ascii_strtoull (value, NULL, 10));
continue;
}
if (g_strcmp0 (tmp, "version") == 0) {
diff --git a/libappstream-glib/as-screenshot.c b/libappstream-glib/as-screenshot.c
index 18e4d7b..672bdf6 100644
--- a/libappstream-glib/as-screenshot.c
+++ b/libappstream-glib/as-screenshot.c
@@ -229,9 +229,9 @@ as_screenshot_get_image_for_locale (AsScreenshot *screenshot,
AsImage *im;
AsImage *im_best = NULL;
AsScreenshotPrivate *priv = GET_PRIVATE (screenshot);
- guint best_size = G_MAXUINT;
+ gint64 best_size = G_MAXINT64;
guint i;
- guint tmp;
+ gint64 tmp;
g_return_val_if_fail (AS_IS_SCREENSHOT (screenshot), NULL);
@@ -487,10 +487,10 @@ as_screenshot_node_parse (AsScreenshot *screenshot, GNode *node,
AsImage *image;
image = as_image_new ();
as_image_set_kind (image, AS_IMAGE_KIND_SOURCE);
- size = as_node_get_attribute_as_int (node, "width");
+ size = as_node_get_attribute_as_uint (node, "width");
if (size != G_MAXINT)
as_image_set_width (image, size);
- size = as_node_get_attribute_as_int (node, "height");
+ size = as_node_get_attribute_as_uint (node, "height");
if (size != G_MAXINT)
as_image_set_height (image, size);
as_image_set_url (image, tmp);
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index c5e404b..84a8d4c 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -468,7 +468,7 @@ as_test_release_func (void)
as_node_unref (root);
/* verify */
- g_assert_cmpint (as_release_get_timestamp (release), ==, 123);
+ g_assert_cmpint ((gint32) as_release_get_timestamp (release), ==, 123);
g_assert_cmpint (as_release_get_urgency (release), ==, AS_URGENCY_KIND_CRITICAL);
g_assert_cmpint (as_release_get_state (release), ==, AS_RELEASE_STATE_UNKNOWN);
g_assert_cmpstr (as_release_get_version (release), ==, "0.1.2");
@@ -515,7 +515,7 @@ as_test_release_date_func (void)
as_node_unref (root);
/* verify */
- g_assert_cmpint (as_release_get_timestamp (release), ==, 1453075200);
+ g_assert_cmpint ((gint32) as_release_get_timestamp (release), ==, 1453075200);
}
static void
@@ -599,7 +599,7 @@ as_test_release_appstream_func (void)
as_node_unref (root);
/* verify */
- g_assert_cmpint (as_release_get_timestamp (release), ==, 123);
+ g_assert_cmpint ((gint32) as_release_get_timestamp (release), ==, 123);
g_assert_cmpstr (as_release_get_version (release), ==, "0.1.2");
g_assert_cmpstr (as_release_get_location_default (release), ==, "http://foo.com/bar.zip");
g_assert_cmpstr (as_release_get_description (release, "pl"), ==,
@@ -678,7 +678,7 @@ as_test_release_appdata_func (void)
as_node_unref (root);
/* verify */
- g_assert_cmpint (as_release_get_timestamp (release), ==, 123);
+ g_assert_cmpint ((gint32) as_release_get_timestamp (release), ==, 123);
g_assert_cmpstr (as_release_get_version (release), ==, "0.1.2");
g_assert_cmpstr (as_release_get_description (release, NULL), ==,
"<p>This is a new release</p>");
@@ -1566,7 +1566,7 @@ as_test_app_validate_check (GPtrArray *array,
g_print ("\n");
for (i = 0; i < array->len; i++) {
problem = g_ptr_array_index (array, i);
- g_print ("%i\t%s\n",
+ g_print ("%u\t%s\n",
as_problem_get_kind (problem),
as_problem_get_message (problem));
}
@@ -2087,7 +2087,7 @@ as_test_app_parse_file_inf_func (void)
releases = as_app_get_releases (app);
g_assert_cmpint (releases->len, ==, 1);
rel = g_ptr_array_index (releases, 0);
- g_assert_cmpint (as_release_get_timestamp (rel), ==, 1425340800);
+ g_assert_cmpint ((gint32) as_release_get_timestamp (rel), ==, 1425340800);
g_assert_cmpstr (as_release_get_version (rel), ==, "0.2.2");
//g_assert_cmpstr (as_release_get_description (rel), ==, "XXX");
}
@@ -2746,7 +2746,7 @@ store_changed_cb (AsStore *store, guint *cnt)
{
as_test_loop_quit ();
(*cnt)++;
- g_debug ("changed callback, now #%i", *cnt);
+ g_debug ("changed callback, now #%u", *cnt);
}
/* automatically reload changed directories */
@@ -4092,7 +4092,7 @@ as_test_store_metadata_index_func (void)
store = as_store_new ();
as_store_add_metadata_index (store, "X-CacheID");
for (i = 0; i < repeats; i++) {
- g_autofree gchar *id = g_strdup_printf ("app-%05i", i);
+ g_autofree gchar *id = g_strdup_printf ("app-%05u", i);
g_autoptr(AsApp) app = as_app_new ();
as_app_set_id (app, id);
as_app_add_metadata (app, "X-CacheID", "dave.i386");
@@ -4606,7 +4606,7 @@ as_test_inf_func (void)
tmp = as_inf_get_driver_version (kf, &ts, &error);
g_assert_no_error (error);
g_assert_cmpstr (tmp, ==, "2.0.0");
- g_assert_cmpint (ts, ==, 1425168000);
+ g_assert_cmpint ((gint32) ts, ==, 1425168000);
g_free (tmp);
/* invalid DriverVer date */
diff --git a/libappstream-glib/as-store-cab.c b/libappstream-glib/as-store-cab.c
index cf5d8ff..319155f 100644
--- a/libappstream-glib/as-store-cab.c
+++ b/libappstream-glib/as-store-cab.c
@@ -257,7 +257,7 @@ as_store_cab_from_bytes_with_origin (AsStore *store,
/* debug */
fn = g_ptr_array_index (filelist, i);
- g_debug ("found file %i\t%s", i, fn);
+ g_debug ("found file %u\t%s", i, fn);
/* if inf or metainfo, add */
if (as_app_guess_source_kind (fn) != AS_APP_SOURCE_KIND_METAINFO)
diff --git a/libappstream-glib/as-store.c b/libappstream-glib/as-store.c
index f2f94b7..7926ad2 100644
--- a/libappstream-glib/as-store.c
+++ b/libappstream-glib/as-store.c
@@ -226,7 +226,7 @@ void
as_store_add_filter (AsStore *store, AsAppKind kind)
{
AsStorePrivate *priv = GET_PRIVATE (store);
- priv->filter |= 1 << kind;
+ priv->filter |= 1u << kind;
}
/**
@@ -246,7 +246,7 @@ void
as_store_remove_filter (AsStore *store, AsAppKind kind)
{
AsStorePrivate *priv = GET_PRIVATE (store);
- priv->filter &= ~(1 << kind);
+ priv->filter &= ~(1u << kind);
}
/**
@@ -1142,7 +1142,7 @@ as_store_from_root (AsStore *store,
AsAppKind kind_tmp;
tmp = as_node_get_attribute (n, "type");
kind_tmp = as_app_kind_from_string (tmp);
- if ((priv->filter & (1 << kind_tmp)) == 0)
+ if ((priv->filter & (1u << kind_tmp)) == 0)
continue;
}
}
@@ -1247,7 +1247,7 @@ as_store_load_yaml_file (AsStore *store,
/* do the filtering here */
if (priv->filter != 0) {
- if ((priv->filter & (1 << as_app_get_kind (app))) == 0)
+ if ((priv->filter & (1u << as_app_get_kind (app))) == 0)
continue;
}
diff --git a/libappstream-glib/as-tag.c b/libappstream-glib/as-tag.c
index e802dcb..1bb78d4 100644
--- a/libappstream-glib/as-tag.c
+++ b/libappstream-glib/as-tag.c
@@ -85,7 +85,7 @@ as_tag_from_string_full (const gchar *tag, AsTagFlags flags)
#ifdef HAVE_GPERF
/* use a perfect hash */
- ky = as_tag_from_gperf (tag, strlen (tag));
+ ky = as_tag_from_gperf (tag, (guint) strlen (tag));
if (ky != NULL)
etag = ky->etag;
#else
diff --git a/libappstream-glib/as-utils.c b/libappstream-glib/as-utils.c
index 30e57ab..78690c8 100644
--- a/libappstream-glib/as-utils.c
+++ b/libappstream-glib/as-utils.c
@@ -608,11 +608,11 @@ as_utils_license_to_spdx (const gchar *license)
/* go through the string looking for case-insensitive matches */
str = g_string_new ("");
- license_len = strlen (license);
+ license_len = (guint) strlen (license);
for (i = 0; i < license_len; i++) {
gboolean found = FALSE;
for (j = 0; convert[j].old != NULL; j++) {
- guint old_len = strlen (convert[j].old);
+ guint old_len = (guint) strlen (convert[j].old);
if (g_ascii_strncasecmp (license + i,
convert[j].old,
old_len) != 0)
@@ -810,13 +810,13 @@ as_pixbuf_sharpen (GdkPixbuf *src, gint radius, gdouble amount)
p_src_row = p_src;
p_blurred_row = p_blurred;
for (x = 0; x < width; x++) {
- p_src_row[0] = interpolate_value (p_src_row[0],
+ p_src_row[0] = (guchar) interpolate_value (p_src_row[0],
p_blurred_row[0],
amount);
- p_src_row[1] = interpolate_value (p_src_row[1],
+ p_src_row[1] = (guchar) interpolate_value (p_src_row[1],
p_blurred_row[1],
amount);
- p_src_row[2] = interpolate_value (p_src_row[2],
+ p_src_row[2] = (guchar) interpolate_value (p_src_row[2],
p_blurred_row[2],
amount);
p_src_row += n_channels;
@@ -1489,7 +1489,7 @@ as_utils_guid_from_string (const gchar *str)
/* hash the namespace and then the string */
csum = g_checksum_new (G_CHECKSUM_SHA1);
g_checksum_update (csum, (guchar *) uu_namespace, 16);
- g_checksum_update (csum, (guchar *) str, strlen(str));
+ g_checksum_update (csum, (guchar *) str, (gssize) strlen (str));
g_checksum_get_digest (csum, hash, &digestlen);
/* copy most parts of the hash 1:1 */
@@ -1519,12 +1519,12 @@ gchar *
as_utils_version_from_uint32 (guint32 val, AsVersionParseFlag flags)
{
if (flags & AS_VERSION_PARSE_FLAG_USE_TRIPLET) {
- return g_strdup_printf ("%i.%i.%i",
+ return g_strdup_printf ("%u.%u.%u",
(val >> 24) & 0xff,
(val >> 16) & 0xff,
val & 0xffff);
}
- return g_strdup_printf ("%i.%i.%i.%i",
+ return g_strdup_printf ("%u.%u.%u.%u",
(val >> 24) & 0xff,
(val >> 16) & 0xff,
(val >> 8) & 0xff,
@@ -1545,9 +1545,9 @@ as_utils_version_from_uint32 (guint32 val, AsVersionParseFlag flags)
gchar *
as_utils_version_from_uint16 (guint16 val, AsVersionParseFlag flags)
{
- return g_strdup_printf ("%i.%i",
- (val >> 8) & 0xff,
- val & 0xff);
+ return g_strdup_printf ("%u.%u",
+ (guint) (val >> 8) & 0xff,
+ (guint) val & 0xff);
}
/**
@@ -1605,7 +1605,7 @@ as_utils_version_parse (const gchar *version)
return g_strdup (version);
if (tmp == 0 || tmp < 0xff)
return g_strdup (version);
- return as_utils_version_from_uint32 (tmp, AS_VERSION_PARSE_FLAG_USE_TRIPLET);
+ return as_utils_version_from_uint32 ((guint32) tmp, AS_VERSION_PARSE_FLAG_USE_TRIPLET);
}
/**
@@ -1637,8 +1637,8 @@ as_utils_string_replace (GString *string, const gchar *search, const gchar *repl
if (string->len == 0)
return 0;
- search_len = strlen (search);
- replace_len = strlen (replace);
+ search_len = (guint) strlen (search);
+ replace_len = (guint) strlen (replace);
do {
tmp = g_strstr_len (string->str + search_idx, -1, search);
@@ -1646,7 +1646,7 @@ as_utils_string_replace (GString *string, const gchar *search, const gchar *repl
break;
/* advance the counter in case @replace contains @search */
- search_idx = tmp - string->str;
+ search_idx = (guint) (tmp - string->str);
/* reallocate the string if required */
if (search_len > replace_len) {
@@ -1703,5 +1703,5 @@ as_utils_iso8601_to_datetime (const gchar *iso_date)
return NULL;
/* create valid object */
- return g_date_time_new_utc (dmy[0], dmy[1], dmy[2], 0, 0, 0);
+ return g_date_time_new_utc ((gint) dmy[0], (gint) dmy[1], (gint) dmy[2], 0, 0, 0);
}
diff --git a/libappstream-glib/as-yaml.c b/libappstream-glib/as-yaml.c
index 8aed749..b1b486d 100644
--- a/libappstream-glib/as-yaml.c
+++ b/libappstream-glib/as-yaml.c
@@ -86,7 +86,25 @@ as_yaml_node_get_value_as_int (const AsNode *node)
return G_MAXINT;
if (value_tmp > G_MAXINT || value_tmp < G_MININT)
return G_MAXINT;
- return value_tmp;
+ return (gint) value_tmp;
+}
+
+guint
+as_yaml_node_get_value_as_uint (const AsNode *node)
+{
+ const gchar *tmp;
+ gchar *endptr = NULL;
+ guint64 value_tmp;
+
+ tmp = as_yaml_node_get_value (node);
+ if (tmp == NULL)
+ return G_MAXUINT;
+ value_tmp = g_ascii_strtoull (tmp, &endptr, 10);
+ if (value_tmp == 0 && tmp == endptr)
+ return G_MAXUINT;
+ if (value_tmp > G_MAXUINT)
+ return G_MAXUINT;
+ return (guint) value_tmp;
}
static gboolean
@@ -114,12 +132,14 @@ as_yaml_to_string_cb (AsNode *node, gpointer data)
{
AsYamlNode *ym = node->data;
GString *str = (GString *) data;
- gint depth;
- gint i;
+ guint depth;
+ guint i;
depth = g_node_depth (node);
- for (i = 0; i < depth - 2; i++)
- g_string_append (str, " ");
+ if (depth >= 2) {
+ for (i = 0; i < depth - 2; i++)
+ g_string_append (str, " ");
+ }
if (ym == NULL)
return FALSE;
switch (ym->kind) {
@@ -256,8 +276,8 @@ as_yaml_from_data (const gchar *data, gssize data_len, GError **error)
/* parse */
yaml_parser_initialize (&parser);
if (data_len < 0)
- data_len = strlen (data);
- yaml_parser_set_input_string (&parser, (guchar *) data, data_len);
+ data_len = (guint) strlen (data);
+ yaml_parser_set_input_string (&parser, (guchar *) data, (gsize) data_len);
node = g_node_new (NULL);
as_node_yaml_process_layer (&parser, node);
yaml_parser_delete (&parser);
@@ -278,7 +298,12 @@ as_yaml_read_handler_cb (void *data,
size_t *size_read)
{
GInputStream *stream = G_INPUT_STREAM (data);
- *size_read = g_input_stream_read (stream, buffer, size, NULL, NULL);
+ *size_read = (gsize) g_input_stream_read (stream,
+ buffer,
+ (gsize)
+ size,
+ NULL,
+ NULL);
return 1;
}
#endif
diff --git a/libappstream-glib/as-yaml.h b/libappstream-glib/as-yaml.h
index 979dd41..99c7975 100644
--- a/libappstream-glib/as-yaml.h
+++ b/libappstream-glib/as-yaml.h
@@ -44,6 +44,7 @@ AsYaml *as_yaml_from_file (GFile *file,
const gchar *as_yaml_node_get_key (const AsYaml *node);
const gchar *as_yaml_node_get_value (const AsYaml *node);
gint as_yaml_node_get_value_as_int (const AsYaml *node);
+guint as_yaml_node_get_value_as_uint (const AsYaml *node);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(AsYaml, as_yaml_unref)