[gcab/wip/hughsie/meson] Fix several -Wsign-compare warnings



commit 0ac5f40d0fd8999c5a16e64725be7ddf8aa654cf
Author: Richard Hughes <richard hughsie com>
Date:   Fri Nov 17 09:37:50 2017 +0000

    Fix several -Wsign-compare warnings

 gcab.c                 |    5 ++---
 libgcab/gcab-cabinet.c |   11 ++++-------
 2 files changed, 6 insertions(+), 10 deletions(-)
---
diff --git a/gcab.c b/gcab.c
index 6be914c..842a58c 100644
--- a/gcab.c
+++ b/gcab.c
@@ -92,7 +92,6 @@ main (int argc, char *argv[])
 {
     GError *error = NULL;
     GOptionContext *context;
-    int i;
 
     gchar **args = NULL;
     gchar *change = NULL;
@@ -174,7 +173,7 @@ individual files from the archive.\
 
         if (list || list_details) {
             GPtrArray *folders = gcab_cabinet_get_folders (cabinet);
-            for (i = 0; i < folders->len; i++) {
+            for (guint i = 0; i < folders->len; i++) {
                 GSList *l, *files = gcab_folder_get_files (g_ptr_array_index (folders, i));
 
                 for (l = files; l != NULL; l = l->next) {
@@ -239,7 +238,7 @@ individual files from the archive.\
 
     folder = gcab_folder_new (compress ? GCAB_COMPRESSION_MSZIP : 0);
 
-    for (i = 1; args[i]; i++) {
+    for (gint i = 1; args[i]; i++) {
         GFile *file = g_file_new_for_commandline_arg (args[i]);
         gchar *name = nopath ? g_path_get_basename (args[i]) : g_strdup (args[i]);
         GCabFile *cabfile = gcab_file_new_with_file (
diff --git a/libgcab/gcab-cabinet.c b/libgcab/gcab-cabinet.c
index b49d296..a0c2843 100644
--- a/libgcab/gcab-cabinet.c
+++ b/libgcab/gcab-cabinet.c
@@ -225,7 +225,6 @@ gcab_cabinet_write (GCabCabinet *self,
     size_t sumstr = 0;
     GSList *l, *files;
     cfile_t *prevf = NULL;
-    int i;
 
     dstream = g_data_output_stream_new (out);
     g_data_output_stream_set_byte_order (dstream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
@@ -248,7 +247,7 @@ gcab_cabinet_write (GCabCabinet *self,
     folder.ndatab = gcab_folder_get_ndatablocks (cabfolder);
 
     /* avoid seeking to allow growing output streams */
-    for (i = 0; i < folder.offsetdata; i++)
+    for (guint i = 0; i < folder.offsetdata; i++)
         if (!g_data_output_stream_put_byte (dstream, 0, cancellable, error))
             goto end;
 
@@ -387,7 +386,6 @@ gcab_cabinet_load (GCabCabinet *self,
 
     gboolean success = FALSE;
     cheader_t cheader;
-    int i;
     GDataInputStream *in = g_data_input_stream_new (stream);
     g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM (in), FALSE);
     g_data_input_stream_set_byte_order (in, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN);
@@ -402,7 +400,7 @@ gcab_cabinet_load (GCabCabinet *self,
                       g_byte_array_new_take (cheader.reserved, cheader.res_header),
                       NULL);
 
-    for (i = 0; i < cheader.nfolders; i++) {
+    for (guint i = 0; i < cheader.nfolders; i++) {
         cfolder_t cfolder = { 0, };
         if (!cfolder_read (&cfolder, cheader.res_folder, in, cancellable, error))
             goto end;
@@ -416,7 +414,7 @@ gcab_cabinet_load (GCabCabinet *self,
         cfolder.reserved = NULL;
     }
 
-    for (i = 0; i < cheader.nfiles; i++) {
+    for (guint i = 0; i < cheader.nfiles; i++) {
         cfile_t cfile = { 0, };
         if (!cfile_read (&cfile, in, cancellable, error))
             goto end;
@@ -475,14 +473,13 @@ gcab_cabinet_extract (GCabCabinet *self,
                       GError **error)
 {
     gboolean success = TRUE;
-    int i;
 
     g_return_val_if_fail (GCAB_IS_CABINET (self), FALSE);
     g_return_val_if_fail (G_IS_FILE (path), FALSE);
     g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
     g_return_val_if_fail (!error || *error == NULL, FALSE);
 
-    for (i = 0; i < self->folders->len; ++i) {
+    for (guint i = 0; i < self->folders->len; ++i) {
         GCabFolder *folder = g_ptr_array_index (self->folders, i);
         if (!gcab_folder_extract (folder, path, self->cheader.res_data,
                                   file_callback, progress_callback, user_data,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]