[file-roller/wip/jtojnar/engrampa-backports] comparison of integer expressions of different signedness: ‘size_t’
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/wip/jtojnar/engrampa-backports] comparison of integer expressions of different signedness: ‘size_t’
- Date: Wed, 27 Jul 2022 17:19:41 +0000 (UTC)
commit a4ba84cd48dfaed6858fde31d8e74f1cd1600ff4
Author: Jan Tojnar <jtojnar gmail com>
Date: Tue Aug 27 13:14:49 2019 +0200
comparison of integer expressions of different signedness: ‘size_t’
Based on https://github.com/mate-desktop/engrampa/commit/e74151786c1ec24929560438590597b493f212e1
Co-Authored-By: rbuj <robert buj gmail com>
meson.build | 2 +-
src/dlg-prop.c | 4 +--
src/file-data.c | 4 +--
src/fr-archive.c | 4 +--
src/fr-command-tar.c | 6 ++--
src/fr-command-unarchiver.c | 3 +-
src/fr-command-zip.c | 2 +-
src/fr-command.c | 16 ++++-------
src/fr-init.c | 36 +++++++-----------------
src/fr-window.c | 67 ++++++++++++++++++---------------------------
src/glib-utils.c | 10 +++----
src/java-utils.c | 9 +++---
12 files changed, 58 insertions(+), 105 deletions(-)
---
diff --git a/meson.build b/meson.build
index d917869f..5d977307 100644
--- a/meson.build
+++ b/meson.build
@@ -120,7 +120,7 @@ if get_option('buildtype').contains('debug')
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wpointer-arith',
- '-Wno-sign-compare',
+ '-Wsign-compare',
'-Wformat-security'
]
else
diff --git a/src/dlg-prop.c b/src/dlg-prop.c
index 33c6bfd7..33d6f689 100644
--- a/src/dlg-prop.c
+++ b/src/dlg-prop.c
@@ -135,9 +135,7 @@ dlg_prop (FrWindow *window)
uncompressed_size = 0;
if (fr_window_archive_is_present (window)) {
- int i;
-
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fd = g_ptr_array_index (window->archive->files, i);
uncompressed_size += fd->size;
}
diff --git a/src/file-data.c b/src/file-data.c
index 836554fa..97d98129 100644
--- a/src/file-data.c
+++ b/src/file-data.c
@@ -140,7 +140,7 @@ int
find_path_in_file_data_array (GPtrArray *array,
const char *path)
{
- int path_l;
+ size_t path_l;
int left, right, p, cmp = -1;
FileData *fd;
@@ -158,7 +158,7 @@ find_path_in_file_data_array (GPtrArray *array,
if (cmp != 0) {
/* consider '/path/to/dir' and '/path/to/dir/' the same path */
- int original_path_l = strlen (fd->original_path);
+ size_t original_path_l = strlen (fd->original_path);
if ((path_l == original_path_l - 1) && (fd->original_path[original_path_l - 1] ==
'/')) {
int cmp2 = strncmp (path, fd->original_path, original_path_l - 1);
if (cmp2 == 0)
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 04c48630..6feb5cc0 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -878,14 +878,12 @@ fr_archive_operation_finish (FrArchive *archive,
success = ! g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
if (success && (g_simple_async_result_get_source_tag (G_SIMPLE_ASYNC_RESULT (result)) ==
fr_archive_list)) {
- int i;
-
/* order the list by name to speed up search */
g_ptr_array_sort (archive->files, file_data_compare_by_path);
/* update the file_data hash */
g_hash_table_remove_all (archive->files_hash);
- for (i = 0; i < archive->files->len; i++) {
+ for (guint i = 0; i < archive->files->len; i++) {
FileData *file_data = g_ptr_array_index (archive->files, i);
g_hash_table_insert (archive->files_hash, file_data->original_path, file_data);
}
diff --git a/src/fr-command-tar.c b/src/fr-command-tar.c
index 22eab489..0b53735d 100644
--- a/src/fr-command-tar.c
+++ b/src/fr-command-tar.c
@@ -1242,9 +1242,8 @@ fr_command_tar_get_capabilities (FrArchive *archive,
}
else if (_g_mime_type_matches (mime_type, "application/x-7z-compressed-tar")) {
char *try_command[5] = { "7zzs", "7zz", "7za", "7zr", "7z" };
- int i;
- for (i = 0; i < G_N_ELEMENTS (try_command); i++) {
+ for (size_t i = 0; i < G_N_ELEMENTS (try_command); i++) {
if (_g_program_is_available (try_command[i], check_command)) {
capabilities |= FR_ARCHIVE_CAN_WRITE;
break;
@@ -1274,9 +1273,8 @@ fr_command_tar_set_mime_type (FrArchive *archive,
if (_g_mime_type_matches (mime_type, "application/x-7z-compressed-tar")) {
char *try_command[5] = { "7zzs", "7zz", "7za", "7zr", "7z" };
- int i;
- for (i = 0; i < G_N_ELEMENTS (try_command); i++) {
+ for (size_t i = 0; i < G_N_ELEMENTS (try_command); i++) {
if (_g_program_is_in_path (try_command[i])) {
comm_tar->compress_command = g_strdup (try_command[i]);
break;
diff --git a/src/fr-command-unarchiver.c b/src/fr-command-unarchiver.c
index 6105e202..9684c63c 100644
--- a/src/fr-command-unarchiver.c
+++ b/src/fr-command-unarchiver.c
@@ -89,10 +89,9 @@ list_command_completed (gpointer data)
if (json_object_get_int_member (root, "lsarFormatVersion") == LSAR_SUPPORTED_FORMAT) {
JsonArray *content;
- int i;
content = json_object_get_array_member (root, "lsarContents");
- for (i = 0; i < json_array_get_length (content); i++) {
+ for (guint i = 0; i < json_array_get_length (content); i++) {
JsonObject *entry;
FileData *fdata;
const char *filename;
diff --git a/src/fr-command-zip.c b/src/fr-command-zip.c
index f25f77b4..79a4384c 100644
--- a/src/fr-command-zip.c
+++ b/src/fr-command-zip.c
@@ -99,7 +99,7 @@ list__process_line (char *line,
FileData *fdata;
char **fields;
const char *name_field;
- gint line_l;
+ size_t line_l;
g_return_if_fail (line != NULL);
diff --git a/src/fr-command.c b/src/fr-command.c
index 377130ce..483e5ca5 100644
--- a/src/fr-command.c
+++ b/src/fr-command.c
@@ -1511,9 +1511,7 @@ delete_from_archive (FrCommand *self,
/* file_list == NULL means delete all the files in the archive. */
if (file_list == NULL) {
- int i;
-
- for (i = 0; i < archive->files->len; i++) {
+ for (guint i = 0; i < archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (archive->files, i);
file_list = g_list_prepend (file_list, fdata->original_path);
}
@@ -1807,7 +1805,7 @@ move_files_in_chunks (FrCommand *self,
{
GList *scan;
char *temp_dir_path;
- int temp_dir_l;
+ size_t temp_dir_l;
char *dest_dir;
temp_dir_path = g_file_get_path (temp_dir);
@@ -2036,7 +2034,7 @@ remove_files_contained_in_this_dir (GList *file_list,
GList *dir_pointer)
{
char *dirname = dir_pointer->data;
- int dirname_l = strlen (dirname);
+ size_t dirname_l = strlen (dirname);
GList *scan;
for (scan = dir_pointer->next; scan; /* empty */) {
@@ -2099,10 +2097,8 @@ _fr_command_extract (FrCommand *self,
extract_all = (file_list == NULL);
if (extract_all && (! all_options_supported || ! archive->propCanExtractAll)) {
- int i;
-
file_list = NULL;
- for (i = 0; i < archive->files->len; i++) {
+ for (guint i = 0; i < archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (archive->files, i);
file_list = g_list_prepend (file_list, g_strdup (fdata->original_path));
}
@@ -2152,10 +2148,8 @@ _fr_command_extract (FrCommand *self,
&& ! archive->propExtractCanJunkPaths)));
if (extract_all && ! file_list_created) {
- int i;
-
file_list = NULL;
- for (i = 0; i < archive->files->len; i++) {
+ for (guint i = 0; i < archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (archive->files, i);
file_list = g_list_prepend (file_list, g_strdup (fdata->original_path));
}
diff --git a/src/fr-init.c b/src/fr-init.c
index 87823c3d..8928e19f 100644
--- a/src/fr-init.c
+++ b/src/fr-init.c
@@ -243,7 +243,6 @@ fr_registered_archive_new (GType command_type)
FrRegisteredArchive *reg_com;
FrArchive *archive;
const char **mime_types;
- int i;
reg_com = g_new0 (FrRegisteredArchive, 1);
reg_com->ref = 1;
@@ -253,7 +252,7 @@ fr_registered_archive_new (GType command_type)
archive = (FrArchive*) g_object_new (reg_com->type, NULL);
mime_types = fr_archive_get_supported_types (archive);
- for (i = 0; mime_types[i] != NULL; i++) {
+ for (size_t i = 0; mime_types[i] != NULL; i++) {
const char *mime_type;
FrMimeTypeCap *cap;
FrMimeTypePackages *packages;
@@ -301,9 +300,7 @@ static FrArchiveCaps
fr_registered_archive_get_capabilities (FrRegisteredArchive *reg_com,
const char *mime_type)
{
- int i;
-
- for (i = 0; i < reg_com->caps->len; i++) {
+ for (guint i = 0; i < reg_com->caps->len; i++) {
FrMimeTypeCap *cap;
cap = g_ptr_array_index (reg_com->caps, i);
@@ -319,12 +316,10 @@ static FrArchiveCaps
fr_registered_archive_get_potential_capabilities (FrRegisteredArchive *reg_com,
const char *mime_type)
{
- int i;
-
if (mime_type == NULL)
return FR_ARCHIVE_CAN_DO_NOTHING;
- for (i = 0; i < reg_com->caps->len; i++) {
+ for (guint i = 0; i < reg_com->caps->len; i++) {
FrMimeTypeCap *cap;
cap = g_ptr_array_index (reg_com->caps, i);
@@ -348,9 +343,7 @@ register_archive (GType command_type)
G_GNUC_UNUSED static gboolean
unregister_archive (GType command_type)
{
- int i;
-
- for (i = 0; i < Registered_Archives->len; i++) {
+ for (guint i = 0; i < Registered_Archives->len; i++) {
FrRegisteredArchive *archive;
archive = g_ptr_array_index (Registered_Archives, i);
@@ -407,12 +400,10 @@ GType
get_archive_type_from_mime_type (const char *mime_type,
FrArchiveCaps requested_capabilities)
{
- int i;
-
if (mime_type == NULL)
return 0;
- for (i = 0; i < Registered_Archives->len; i++) {
+ for (guint i = 0; i < Registered_Archives->len; i++) {
FrRegisteredArchive *command;
FrArchiveCaps capabilities;
@@ -432,9 +423,7 @@ GType
get_preferred_archive_for_mime_type (const char *mime_type,
FrArchiveCaps requested_capabilities)
{
- int i;
-
- for (i = 0; i < Registered_Archives->len; i++) {
+ for (guint i = 0; i < Registered_Archives->len; i++) {
FrRegisteredArchive *archive;
FrArchiveCaps capabilities;
@@ -453,18 +442,15 @@ get_preferred_archive_for_mime_type (const char *mime_type,
void
update_registered_archives_capabilities (void)
{
- int i;
-
g_hash_table_remove_all (ProgramsCache);
- for (i = 0; i < Registered_Archives->len; i++) {
+ for (guint i = 0; i < Registered_Archives->len; i++) {
FrRegisteredArchive *reg_com;
FrArchive *archive;
- int j;
reg_com = g_ptr_array_index (Registered_Archives, i);
archive = g_object_new (reg_com->type, NULL);
- for (j = 0; j < reg_com->caps->len; j++) {
+ for (guint j = 0; j < reg_com->caps->len; j++) {
FrMimeTypeCap *cap = g_ptr_array_index (reg_com->caps, j);
cap->current_capabilities = fr_archive_get_capabilities (archive, cap->mime_type,
TRUE);
@@ -599,14 +585,12 @@ static void
compute_supported_archive_types (void)
{
int sf_i = 0, s_i = 0, o_i = 0, c_i = 0;
- int i;
- for (i = 0; i < Registered_Archives->len; i++) {
+ for (guint i = 0; i < Registered_Archives->len; i++) {
FrRegisteredArchive *reg_com;
- int j;
reg_com = g_ptr_array_index (Registered_Archives, i);
- for (j = 0; j < reg_com->caps->len; j++) {
+ for (guint j = 0; j < reg_com->caps->len; j++) {
FrMimeTypeCap *cap;
int idx;
diff --git a/src/fr-window.c b/src/fr-window.c
index ad5f684e..6791697a 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -926,8 +926,7 @@ static gboolean
fr_window_dir_exists_in_archive (FrWindow *window,
const char *dir_name)
{
- int dir_name_len;
- int i;
+ size_t dir_name_len;
if (dir_name == NULL)
return FALSE;
@@ -939,7 +938,7 @@ fr_window_dir_exists_in_archive (FrWindow *window,
if (strcmp (dir_name, "/") == 0)
return TRUE;
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (window->archive->files, i);
if (strncmp (dir_name, fdata->full_path, dir_name_len) == 0) {
@@ -1174,11 +1173,10 @@ static GPtrArray *
fr_window_get_current_dir_list (FrWindow *window)
{
GPtrArray *files;
- int i;
files = g_ptr_array_sized_new (128);
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (window->archive->files, i);
if (fdata->list_name == NULL)
@@ -1225,14 +1223,13 @@ get_dir_size (FrWindow *window,
{
guint64 size;
char *dirname;
- int dirname_l;
- int i;
+ size_t dirname_l;
dirname = g_strconcat (current_dir, name, "/", NULL);
dirname_l = strlen (dirname);
size = 0;
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fd = g_ptr_array_index (window->archive->files, i);
if (strncmp (dirname, fd->full_path, dirname_l) == 0)
@@ -1265,7 +1262,7 @@ compute_file_list_name (FrWindow *window,
GRegex *filter,
FileData *fdata,
const char *current_dir,
- int current_dir_len,
+ size_t current_dir_len,
GHashTable *names_hash,
gboolean *different_name)
{
@@ -1350,10 +1347,9 @@ fr_window_compute_list_names (FrWindow *window,
GPtrArray *files)
{
const char *current_dir;
- int current_dir_len;
+ size_t current_dir_len;
GHashTable *names_hash;
GRegex *filter;
- int i;
gboolean visible_list_started = FALSE;
gboolean visible_list_completed = FALSE;
gboolean different_name;
@@ -1363,7 +1359,7 @@ fr_window_compute_list_names (FrWindow *window,
names_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
filter = _fr_window_create_filter (window);
- for (i = 0; i < files->len; i++) {
+ for (guint i = 0; i < files->len; i++) {
FileData *fdata = g_ptr_array_index (files, i);
file_data_set_list_name (fdata, NULL);
@@ -1521,7 +1517,6 @@ fr_window_populate_file_list (FrWindow *window,
{
int sort_column_id;
GtkSortType order;
- int i;
if (! gtk_widget_get_realized (GTK_WIDGET (window))) {
_fr_window_stop_activity_mode (window);
@@ -1538,7 +1533,7 @@ fr_window_populate_file_list (FrWindow *window,
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
0);
- for (i = 0; i < files->len; i++) {
+ for (guint i = 0; i < files->len; i++) {
FileData *fdata = g_ptr_array_index (files, i);
GtkTreeIter iter;
GdkPixbuf *icon, *emblem;
@@ -1742,7 +1737,6 @@ fr_window_update_dir_tree (FrWindow *window)
GPtrArray *dirs;
GRegex *filter;
GHashTable *dir_cache;
- int i;
GdkPixbuf *icon;
if (! gtk_widget_get_realized (GTK_WIDGET (window)))
@@ -1773,7 +1767,7 @@ fr_window_update_dir_tree (FrWindow *window)
filter = _fr_window_create_filter (window);
dir_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (window->archive->files, i);
char *dir;
@@ -1832,7 +1826,7 @@ fr_window_update_dir_tree (FrWindow *window)
/**/
icon = get_mime_type_icon (window, MIME_TYPE_DIRECTORY);
- for (i = 0; i < dirs->len; i++) {
+ for (guint i = 0; i < dirs->len; i++) {
char *dir = g_ptr_array_index (dirs, i);
char *parent_dir;
GtkTreePath *parent_path;
@@ -3270,16 +3264,15 @@ get_dir_list_from_path (FrWindow *window,
char *path)
{
char *dirname;
- int dirname_l;
+ size_t dirname_l;
GList *list = NULL;
- int i;
if (path[strlen (path) - 1] != '/')
dirname = g_strconcat (path, "/", NULL);
else
dirname = g_strdup (path);
dirname_l = strlen (dirname);
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fd = g_ptr_array_index (window->archive->files, i);
gboolean matches = FALSE;
@@ -3288,7 +3281,7 @@ get_dir_list_from_path (FrWindow *window,
#endif
if (fd->dir) {
- int full_path_l = strlen (fd->full_path);
+ size_t full_path_l = strlen (fd->full_path);
if ((full_path_l == dirname_l - 1) && (strncmp (dirname, fd->full_path, full_path_l)
== 0))
/* example: dirname is '/path/to/dir/' and fd->full_path is '/path/to/dir' */
matches = TRUE;
@@ -3475,13 +3468,12 @@ fr_window_get_file_list_pattern (FrWindow *window,
{
GRegex **regexps;
GList *list;
- int i;
g_return_val_if_fail (window != NULL, NULL);
regexps = _g_regexp_split_from_patterns (pattern, G_REGEX_CASELESS);
list = NULL;
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fd = g_ptr_array_index (window->archive->files, i);
char *utf8_name;
@@ -3503,12 +3495,11 @@ static GList *
fr_window_get_file_list (FrWindow *window)
{
GList *list;
- int i;
g_return_val_if_fail (window != NULL, NULL);
list = NULL;
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fd = g_ptr_array_index (window->archive->files, i);
list = g_list_prepend (list, g_strdup (fd->original_path));
}
@@ -3941,13 +3932,12 @@ get_file_list_from_selection_data (char *uri_list)
{
GList *list = NULL;
char **uris;
- int i;
if (uri_list == NULL)
return NULL;
uris = g_uri_list_extract_uris (uri_list);
- for (i = 0; uris[i] != NULL; i++)
+ for (size_t i = 0; uris[i] != NULL; i++)
list = g_list_prepend (list, g_file_new_for_uri (uris[i]));
g_strfreev (uris);
@@ -3985,7 +3975,6 @@ get_clipboard_data_from_selection_data (FrWindow *window,
{
FrClipboardData *clipboard_data;
char **uris;
- int i;
clipboard_data = fr_clipboard_data_new ();
@@ -3998,7 +3987,7 @@ get_clipboard_data_from_selection_data (FrWindow *window,
clipboard_data->password = g_strdup (uris[1]);
clipboard_data->op = (strcmp (uris[2], "copy") == 0) ? FR_CLIPBOARD_OP_COPY : FR_CLIPBOARD_OP_CUT;
clipboard_data->base_dir = g_strdup (uris[3]);
- for (i = 4; uris[i] != NULL; i++)
+ for (size_t i = 4; uris[i] != NULL; i++)
if (uris[i][0] != '\0')
clipboard_data->files = g_list_prepend (clipboard_data->files, g_strdup (uris[i]));
clipboard_data->files = g_list_reverse (clipboard_data->files);
@@ -4992,7 +4981,7 @@ add_file_list_columns (FrWindow *window,
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GValue value = { 0, };
- int i, j, w;
+ int w;
/* First column. */
@@ -5048,7 +5037,7 @@ add_file_list_columns (FrWindow *window,
/* Other columns */
- for (j = 0, i = COLUMN_SIZE; i < NUMBER_OF_COLUMNS; i++, j++) {
+ for (guint j = 0, i = COLUMN_SIZE; i < NUMBER_OF_COLUMNS; i++, j++) {
GValue value = { 0, };
renderer = gtk_cell_renderer_text_new ();
@@ -6403,10 +6392,9 @@ archive_extraction_ready_cb (GObject *source_object,
GHashTable *names_hash;
gboolean stop = FALSE;
- int i;
names_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- for (i = 0; ! stop && (i < window->archive->files->len); i++) {
+ for (guint i = 0; ! stop && (i < window->archive->files->len); i++) {
FileData *fdata = g_ptr_array_index (window->archive->files, i);
char *first_level;
char *second_slash;
@@ -6740,9 +6728,7 @@ archive_is_encrypted (FrWindow *window,
gboolean encrypted = FALSE;
if (file_list == NULL) {
- int i;
-
- for (i = 0; ! encrypted && i < window->archive->files->len; i++) {
+ for (guint i = 0; ! encrypted && i < window->archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (window->archive->files, i);
if (fdata->encrypted)
@@ -6913,11 +6899,11 @@ _archive_extraction_generates_a_tarbomb (FrArchive *archive)
{
gboolean tarbomb = FALSE;
GHashTable *names_hash;
- int n_toplevel_items, i;
+ guint n_toplevel_items;
names_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
n_toplevel_items = 0;
- for (i = 0; ! tarbomb && (i < archive->files->len); i++) {
+ for (guint i = 0; ! tarbomb && (i < archive->files->len); i++) {
FileData *fdata = g_ptr_array_index (archive->files, i);
char *second_separator;
char *name = NULL;
@@ -8218,16 +8204,15 @@ name_is_present (FrWindow *window,
char **reason)
{
gboolean retval = FALSE;
- int i;
char *new_filename;
- int new_filename_l;
+ size_t new_filename_l;
*reason = NULL;
new_filename = g_build_filename (current_dir, new_name, NULL);
new_filename_l = strlen (new_filename);
- for (i = 0; i < window->archive->files->len; i++) {
+ for (guint i = 0; i < window->archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (window->archive->files, i);
const char *filename = fdata->full_path;
diff --git a/src/glib-utils.c b/src/glib-utils.c
index ac077fcc..a9bc3b1d 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -948,7 +948,7 @@ _g_path_get_relative_basename (const char *path,
const char *base_dir,
gboolean junk_paths)
{
- int base_dir_len;
+ size_t base_dir_len;
const char *base_path;
if (junk_paths)
@@ -1059,7 +1059,7 @@ gboolean
_g_filename_has_extension (const char *filename,
const char *ext)
{
- int filename_l, ext_l;
+ size_t filename_l, ext_l;
filename_l = strlen (filename);
ext_l = strlen (ext);
@@ -1136,9 +1136,7 @@ _g_mime_type_get_from_content (char *buffer,
{ 0, 4, "\x28\xB5\x2F\xFD", "application/zstd" },
};
- int i;
-
- for (i = 0; i < G_N_ELEMENTS (magic_ids); i++) {
+ for (size_t i = 0; i < G_N_ELEMENTS (magic_ids); i++) {
const struct magic * const magic = &magic_ids[i];
if ((magic->off + magic->len) > buffer_size)
@@ -1382,7 +1380,7 @@ int
_g_line_get_index_from_pattern (const char *line,
const char *pattern)
{
- int line_l, pattern_l;
+ size_t line_l, pattern_l;
const char *l;
line_l = strlen (line);
diff --git a/src/java-utils.c b/src/java-utils.c
index 3bd132e9..adf65cea 100644
--- a/src/java-utils.c
+++ b/src/java-utils.c
@@ -250,7 +250,6 @@ get_package_name_from_class_file (char *fname)
guint16 length = 0, end = 0, utf_index = 0;
guint32 magic;
guint16 major, minor, count;
- int i = 0;
if (! g_file_test (fname, G_FILE_TEST_EXISTS))
return NULL;
@@ -260,7 +259,7 @@ get_package_name_from_class_file (char *fname)
if (cfile->fd == -1)
return close_and_exit (cfile);
- if ((i = read (cfile->fd, &magic, 4)) != 4)
+ if (read (cfile->fd, &magic, 4) != 4)
return close_and_exit (cfile);
cfile->magic_no = GUINT32_FROM_BE (magic);
@@ -287,7 +286,7 @@ get_package_name_from_class_file (char *fname)
/* now search for the class structure with index = cfile->this_class */
- for (i = 0; (i < g_slist_length (cfile->const_pool_class)) && (utf_index == 0); i++ ) {
+ for (guint i = 0; (i < g_slist_length (cfile->const_pool_class)) && (utf_index == 0); i++ ) {
struct class_info *class = g_slist_nth_data (cfile->const_pool_class, i);
if (class->index == cfile->this_class)
utf_index = class->name_index; /* terminates loop */
@@ -295,7 +294,7 @@ get_package_name_from_class_file (char *fname)
/* now search for the utf8 string with index = utf_index */
- for (i = 0; i < g_slist_length (cfile->const_pool_utf); i++) {
+ for (guint i = 0; i < g_slist_length (cfile->const_pool_utf); i++) {
struct utf_string *data = g_slist_nth_data (cfile->const_pool_utf, i);
if (data->index == utf_index) {
package = g_strndup (data->str, data->length);
@@ -307,7 +306,7 @@ get_package_name_from_class_file (char *fname)
if (package != NULL) {
char *tmp;
- for (i = length; (i >= 0) && (end == 0); i--)
+ for (int i = length; (i >= 0) && (end == 0); i--)
if (package[i] == '/')
end = i;
tmp = g_strndup (package, end);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]