Skip to content

Commit b6d4603

Browse files
rbujlukefromdc
authored andcommittedFeb 9, 2022
Fix some -Wsign-compare warnings
1 parent 97b61e6 commit b6d4603

16 files changed

+75
-63
lines changed
 

‎eel/eel-gtk-extensions.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,25 @@ static void
115115
sanity_check_window_dimensions (guint *width, guint *height)
116116
{
117117
GdkScreen *screen;
118-
gint scale;
118+
int screen_width;
119+
int screen_height;
120+
int scale;
119121

120122
g_assert (width != NULL);
121123
g_assert (height != NULL);
122124

123125
screen = gdk_screen_get_default ();
124126
scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
127+
screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
128+
screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
125129

126130
/* Pin the size of the window to the screen, so we don't end up in
127131
* a state where the window is so big essential parts of it can't
128132
* be reached (might not be necessary with all window managers,
129133
* but seems reasonable anyway).
130134
*/
131-
*width = MIN (*width, WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale);
132-
*height = MIN (*height, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale);
135+
*width = MIN (*width, (guint) screen_width);
136+
*height = MIN (*height, (guint) screen_height);
133137
}
134138

135139
/**

‎libcaja-private/caja-debug-log.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ caja_debug_log_load_configuration (const char *filename, GError **error)
358358
g_error_free (my_error);
359359
else
360360
{
361-
int i;
361+
gsize i;
362362

363363
for (i = 0; i < num_strings; i++)
364364
strings[i] = g_strstrip (strings[i]);

‎libcaja-private/caja-desktop-metadata.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ caja_desktop_update_metadata_from_keyfile (CajaFile *file,
240240
gsize length, values_length;
241241
GKeyFile *keyfile;
242242
GFileInfo *info;
243-
gint idx;
243+
gsize idx;
244244
gboolean res;
245245

246246
keyfile = get_keyfile ();

‎libcaja-private/caja-file-operations.c

+23-21
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ get_link_name (const char *name, int count, int max_length)
376376
{
377377
const char *format;
378378
char *result;
379-
int unshortened_length;
379+
size_t unshortened_length;
380380
gboolean use_count;
381381

382382
g_assert (name != NULL);
@@ -444,10 +444,10 @@ get_link_name (const char *name, int count, int max_length)
444444
else
445445
result = g_strdup_printf (format, name);
446446

447-
if (max_length > 0 && (unshortened_length = strlen (result)) > max_length) {
447+
if (max_length > 0 && (unshortened_length = strlen (result)) > (size_t) max_length) {
448448
char *new_name;
449449

450-
new_name = shorten_utf8_string (name, unshortened_length - max_length);
450+
new_name = shorten_utf8_string (name, ((int) unshortened_length) - max_length);
451451
if (new_name) {
452452
g_free (result);
453453

@@ -456,7 +456,7 @@ get_link_name (const char *name, int count, int max_length)
456456
else
457457
result = g_strdup_printf (format, new_name);
458458

459-
g_assert (strlen (result) <= max_length);
459+
g_assert (strlen (result) <= (size_t) max_length);
460460
g_free (new_name);
461461
}
462462
}
@@ -655,7 +655,7 @@ make_next_duplicate_name (const char *base, const char *suffix, int count, int m
655655
{
656656
const char *format;
657657
char *result;
658-
int unshortened_length;
658+
size_t unshortened_length;
659659
gboolean use_count;
660660

661661
if (count < 1) {
@@ -733,10 +733,10 @@ make_next_duplicate_name (const char *base, const char *suffix, int count, int m
733733
else
734734
result = g_strdup_printf (format, base, suffix);
735735

736-
if (max_length > 0 && (unshortened_length = strlen (result)) > max_length) {
736+
if (max_length > 0 && (unshortened_length = strlen (result)) > (size_t) max_length) {
737737
char *new_base;
738738

739-
new_base = shorten_utf8_string (base, unshortened_length - max_length);
739+
new_base = shorten_utf8_string (base, ((int) unshortened_length) - max_length);
740740
if (new_base) {
741741
g_free (result);
742742

@@ -745,7 +745,7 @@ make_next_duplicate_name (const char *base, const char *suffix, int count, int m
745745
else
746746
result = g_strdup_printf (format, new_base, suffix);
747747

748-
g_assert (strlen (result) <= max_length);
748+
g_assert (strlen (result) <= (size_t) max_length);
749749
g_free (new_base);
750750
}
751751
}
@@ -1778,7 +1778,7 @@ delete_file (CommonJob *job, GFile *file,
17781778
}
17791779

17801780
static void
1781-
delete_files (CommonJob *job, GList *files, int *files_skipped)
1781+
delete_files (CommonJob *job, GList *files, guint *files_skipped)
17821782
{
17831783
GList *l;
17841784
SourceInfo source_info;
@@ -1821,10 +1821,10 @@ delete_files (CommonJob *job, GList *files, int *files_skipped)
18211821

18221822
static void
18231823
report_trash_progress (CommonJob *job,
1824-
int files_trashed,
1825-
int total_files)
1824+
guint files_trashed,
1825+
guint total_files)
18261826
{
1827-
int files_left;
1827+
guint files_left;
18281828
char *s;
18291829

18301830
files_left = total_files - files_trashed;
@@ -1844,13 +1844,13 @@ report_trash_progress (CommonJob *job,
18441844
}
18451845

18461846
static void
1847-
trash_files (CommonJob *job, GList *files, int *files_skipped)
1847+
trash_files (CommonJob *job, GList *files, guint *files_skipped)
18481848
{
18491849
GList *l;
18501850
GFile *file;
18511851
GList *to_delete;
18521852
GError *error;
1853-
int total_files, files_trashed;
1853+
guint total_files, files_trashed;
18541854
char *primary, *secondary, *details;
18551855
int response;
18561856

@@ -1978,7 +1978,7 @@ delete_job (GIOSchedulerJob *io_job,
19781978
gboolean must_confirm_delete_in_trash;
19791979
gboolean must_confirm_delete;
19801980
gboolean must_confirm_trash;
1981-
int files_skipped;
1981+
guint files_skipped;
19821982
GFile *file = NULL;
19831983

19841984
common = (CommonJob *)job;
@@ -2923,11 +2923,11 @@ verify_destination (CommonJob *job,
29232923
free_size = g_file_info_get_attribute_uint64 (fsinfo,
29242924
G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
29252925

2926-
if (free_size < required_size) {
2926+
if (free_size < (guint64) required_size) {
29272927
primary = f (_("Error while copying to \"%B\"."), dest);
29282928
secondary = f(_("There is not enough space on the destination. Try to remove files to make space."));
29292929

2930-
details = f (_("There is %S available, but %S is required."), free_size, required_size);
2930+
details = f (_("There is %" G_GUINT64_FORMAT " available, but %" G_GOFFSET_FORMAT " is required."), free_size, required_size);
29312931

29322932
response = run_warning (job,
29332933
primary,
@@ -3174,7 +3174,7 @@ make_file_name_valid_for_dest_fs (char *filename,
31743174
!strcmp (dest_fs_type, "msdos") ||
31753175
!strcmp (dest_fs_type, "msdosfs")) {
31763176
gboolean ret;
3177-
int i, old_len;
3177+
size_t i, old_len;
31783178

31793179
ret = str_replace (filename, FAT_FORBIDDEN_CHARACTERS, '_');
31803180

@@ -6134,11 +6134,13 @@ create_job (GIOSchedulerJob *io_job,
61346134
if (count == 1) {
61356135
new_filename = g_strdup (filename);
61366136
} else if (job->make_dir) {
6137-
filename2 = g_strdup_printf ("%s %d", filename, count);
6137+
size_t unshortened_length;
61386138

6139+
filename2 = g_strdup_printf ("%s %d", filename, count);
6140+
unshortened_length = strlen (filename2);
61396141
new_filename = NULL;
6140-
if (max_length > 0 && strlen (filename2) > max_length) {
6141-
new_filename = shorten_utf8_string (filename2, strlen (filename2) - max_length);
6142+
if (max_length > 0 && unshortened_length > (size_t) max_length) {
6143+
new_filename = shorten_utf8_string (filename2, ((int) unshortened_length) - max_length);
61426144
}
61436145

61446146
if (new_filename == NULL) {

‎libcaja-private/caja-file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -6254,9 +6254,9 @@ caja_file_get_size_as_string (CajaFile *file,
62546254
}
62556255

62566256
if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS))
6257-
return g_format_size_full (size, G_FORMAT_SIZE_IEC_UNITS);
6257+
return g_format_size_full ((guint64) size, G_FORMAT_SIZE_IEC_UNITS);
62586258
else
6259-
return g_format_size (size);
6259+
return g_format_size ((guint64) size);
62606260
}
62616261

62626262
/**

‎libcaja-private/caja-query.c

-5
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,6 @@ caja_query_parse_xml (char *xml, gsize xml_len)
335335
ParserInfo info = { NULL };
336336
GMarkupParseContext *ctx;
337337

338-
if (xml_len == -1)
339-
{
340-
xml_len = strlen (xml);
341-
}
342-
343338
info.query = caja_query_new ();
344339
info.in_text = FALSE;
345340

‎src/caja-application.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ open_tabs (CajaApplication *application,
283283
CajaApplication *self = CAJA_APPLICATION (application);
284284
CajaWindow *window;
285285
gchar *uri = NULL;
286+
guint i;
286287

287288
/* monitor the preference to use browser or spatial windows */
288289
/* connect before trying to read or this preference won't be read by root or after change */
@@ -307,7 +308,7 @@ open_tabs (CajaApplication *application,
307308
g_debug ("Opening new tab at uri %s\n", uri);
308309
caja_window_go_to (window, locations[0]);
309310
g_free (uri);
310-
for (int i = 1; i< n_files;i++) {
311+
for (i = 1; i < n_files; i++) {
311312
/* open tabs in reverse order because each
312313
* tab is opened before the previous one */
313314
guint tab = n_files-i;

‎src/caja-connect-server-dialog.c

+16-7
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ enum
9292
RESPONSE_CONNECT
9393
};
9494

95+
enum {
96+
COL_TYPE_COMBO_INDEX = 0,
97+
COL_TYPE_COMBO_DESCRIPTION,
98+
COL_TYPE_COMBO_NUM
99+
};
100+
95101
struct MethodInfo
96102
{
97103
const char *scheme;
@@ -532,7 +538,7 @@ connect_dialog_connect_to_server (CajaConnectServerDialog *dialog)
532538
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), &iter);
533539
gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->details->type_combo)),
534540
&iter, 0, &index, -1);
535-
g_assert (index < G_N_ELEMENTS (methods) && index >= 0);
541+
g_assert (index >= 0 && ((gsize) index) < G_N_ELEMENTS (methods));
536542
meth = &(methods[index]);
537543

538544
server = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->server_entry), 0, -1);
@@ -778,7 +784,7 @@ connect_dialog_setup_for_type (CajaConnectServerDialog *dialog)
778784

779785
gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->details->type_combo)),
780786
&iter, 0, &index, -1);
781-
g_assert (index < G_N_ELEMENTS (methods) && index >= 0);
787+
g_assert (index >= 0 && ((gsize) index) < G_N_ELEMENTS (methods));
782788
meth = &(methods[index]);
783789

784790
g_object_set (dialog->details->share_entry,
@@ -847,7 +853,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog)
847853
GtkListStore *store;
848854
GtkCellRenderer *renderer;
849855
gchar *str;
850-
int i;
856+
gsize i;
851857

852858
dialog->details = caja_connect_server_dialog_get_instance_private (dialog);
853859

@@ -932,13 +938,16 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog)
932938
dialog->details->type_combo = combo = gtk_combo_box_new ();
933939

934940
/* each row contains: method index, textual description */
935-
store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
941+
store = gtk_list_store_new (COL_TYPE_COMBO_NUM,
942+
G_TYPE_INT, /* COL_TYPE_COMBO_INDEX */
943+
G_TYPE_STRING); /* COL_TYPE_COMBO_DESCRIPTION */
936944
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
937945
g_object_unref (store);
938946

939947
renderer = gtk_cell_renderer_text_new ();
940948
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
941-
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text", 1);
949+
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), renderer, "text",
950+
COL_TYPE_COMBO_DESCRIPTION);
942951

943952
for (i = 0; i < G_N_ELEMENTS (methods); i++)
944953
{
@@ -971,8 +980,8 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog)
971980

972981
gtk_list_store_append (store, &iter);
973982
gtk_list_store_set (store, &iter,
974-
0, i,
975-
1, get_method_description (&(methods[i])),
983+
COL_TYPE_COMBO_INDEX, (int) i,
984+
COL_TYPE_COMBO_DESCRIPTION, get_method_description (&(methods[i])),
976985
-1);
977986

978987
if (methods[i].flags & DEFAULT_METHOD)

‎src/caja-file-management-properties.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ update_caption_combo_box (GtkBuilder *builder,
384384
const char *name)
385385
{
386386
GtkWidget *combo_box;
387-
int i;
387+
guint i;
388388
GPtrArray *column_names;
389389

390390
combo_box = GTK_WIDGET (gtk_builder_get_object (builder, combo_box_name));
@@ -401,7 +401,7 @@ update_caption_combo_box (GtkBuilder *builder,
401401
{
402402
if (!strcmp (name, g_ptr_array_index (column_names, i)))
403403
{
404-
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), i);
404+
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), (int) i);
405405
break;
406406
}
407407
}
@@ -842,7 +842,7 @@ caja_file_management_properties_dialog_setup_extension_page (GtkBuilder *builder
842842
gchar *ext_text_info;
843843

844844
GList *extensions;
845-
int i;
845+
guint i;
846846

847847
extensions = caja_extensions_get_list ();
848848

‎src/caja-image-properties-page.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ file_read_callback (GObject *object,
472472
{
473473
int exif_still_loading;
474474

475-
g_assert (count_read <= sizeof(page->details->buffer));
475+
g_assert (((size_t) count_read) <= sizeof (page->details->buffer));
476476

477477
#ifdef HAVE_EXIF
478478
exif_still_loading = exif_loader_write (page->details->exifldr,

‎src/caja-navigation-window.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ caja_navigation_window_key_press_event (GtkWidget *widget,
519519
GdkEventKey *event)
520520
{
521521
CajaNavigationWindow *window;
522-
int i;
522+
gsize i;
523523

524524
window = CAJA_NAVIGATION_WINDOW (widget);
525525

@@ -604,12 +604,12 @@ caja_navigation_window_button_press_event (GtkWidget *widget,
604604
handled = FALSE;
605605
window = CAJA_NAVIGATION_WINDOW (widget);
606606

607-
if (mouse_extra_buttons && (event->button == mouse_back_button))
607+
if (mouse_extra_buttons && (((int) event->button) == mouse_back_button))
608608
{
609609
caja_navigation_window_go_back (window);
610610
handled = TRUE;
611611
}
612-
else if (mouse_extra_buttons && (event->button == mouse_forward_button))
612+
else if (mouse_extra_buttons && (((int) event->button) == mouse_forward_button))
613613
{
614614
caja_navigation_window_go_forward (window);
615615
handled = TRUE;
@@ -1082,7 +1082,7 @@ gint
10821082
caja_navigation_window_get_base_page_index (CajaNavigationWindow *window)
10831083
{
10841084
CajaNavigationWindowSlot *slot;
1085-
gint forward_count;
1085+
guint forward_count;
10861086

10871087
slot = CAJA_NAVIGATION_WINDOW_SLOT (CAJA_WINDOW (window)->details->active_pane->active_slot);
10881088

@@ -1097,7 +1097,7 @@ caja_navigation_window_get_base_page_index (CajaNavigationWindow *window)
10971097
/* The forward count indicate the relative postion of the base page
10981098
* in the history list
10991099
*/
1100-
return forward_count;
1100+
return (int) forward_count;
11011101
}
11021102

11031103
/**

‎src/caja-places-sidebar.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,7 @@ reorder_bookmarks (CajaPlacesSidebar *sidebar,
14611461
GtkTreeIter iter;
14621462
PlaceType type;
14631463
int old_position;
1464+
guint list_length;
14641465

14651466
/* Get the selected path */
14661467

@@ -1472,12 +1473,12 @@ reorder_bookmarks (CajaPlacesSidebar *sidebar,
14721473
PLACES_SIDEBAR_COLUMN_INDEX, &old_position,
14731474
-1);
14741475

1475-
if (type != PLACES_BOOKMARK ||
1476-
old_position < 0 ||
1477-
old_position >= caja_bookmark_list_length (sidebar->bookmarks))
1478-
{
1476+
if (type != PLACES_BOOKMARK || old_position < 0)
1477+
return;
1478+
1479+
list_length = caja_bookmark_list_length (sidebar->bookmarks);
1480+
if (((guint) old_position) >= list_length)
14791481
return;
1480-
}
14811482

14821483
caja_bookmark_list_move_item (sidebar->bookmarks, old_position,
14831484
new_position);

‎src/caja-query-editor.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ tags_row_add_to_query (CajaQueryEditorRow *row,
468468

469469
char **strv = g_strsplit (tags, " ", -1);
470470
guint len = g_strv_length (strv);
471-
int i;
471+
guint i;
472472

473473
for (i = 0; i < len; ++i) {
474474
strv[i] = g_strstrip (strv[i]);
@@ -839,7 +839,7 @@ type_row_create_widgets (CajaQueryEditorRow *row)
839839
GtkCellRenderer *cell;
840840
GtkListStore *store;
841841
GtkTreeIter iter;
842-
int i;
842+
gsize i;
843843

844844
store = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN);
845845
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
@@ -993,7 +993,7 @@ type_add_rows_from_query (CajaQueryEditor *editor,
993993
char *mime_type;
994994
CajaQueryEditorRow *row;
995995
GtkTreeIter iter;
996-
int i;
996+
gsize i;
997997
GtkTreeModel *model;
998998
GList *l;
999999

@@ -1017,7 +1017,7 @@ type_add_rows_from_query (CajaQueryEditor *editor,
10171017

10181018
model = gtk_combo_box_get_model (GTK_COMBO_BOX (row->type_widget));
10191019

1020-
gtk_tree_model_iter_nth_child (model, &iter, NULL, i + 2);
1020+
gtk_tree_model_iter_nth_child (model, &iter, NULL, ((gint) i) + 2);
10211021
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (row->type_widget),
10221022
&iter);
10231023
}

‎src/caja-window.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ caja_window_key_press_event (GtkWidget *widget,
10731073
return TRUE;
10741074

10751075
CajaWindow *window;
1076-
int i;
1076+
gsize i;
10771077

10781078
window = CAJA_WINDOW (widget);
10791079

‎src/file-manager/fm-directory-view.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2351,9 +2351,9 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
23512351
char *size_string;
23522352

23532353
if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS))
2354-
size_string = g_format_size_full (non_folder_size, G_FORMAT_SIZE_IEC_UNITS);
2354+
size_string = g_format_size_full ((guint64) non_folder_size, G_FORMAT_SIZE_IEC_UNITS);
23552355
else
2356-
size_string = g_format_size(non_folder_size);
2356+
size_string = g_format_size ((guint64) non_folder_size);
23572357

23582358
/* Translators: This is marked for translation in case a localiser
23592359
* needs to use something other than parentheses. The

‎src/file-manager/fm-properties-window.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4139,7 +4139,7 @@ permission_combo_update (FMPropertiesWindow *window,
41394139
int current_perm;
41404140
gtk_tree_model_get (model, &iter, 1, &current_perm, -1);
41414141

4142-
if (current_perm == all_perm) {
4142+
if (((PermissionValue) current_perm) == all_perm) {
41434143
found = TRUE;
41444144
break;
41454145
}

0 commit comments

Comments
 (0)
Please sign in to comment.