From e2723bc22e71490eb988438fce733a3a9e47e899 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Fri, 2 Feb 2024 16:34:35 +0000 Subject: [PATCH] clang-tidy: modernize-use-auto - Fix warnings identified by this flag - Remove the exclude from .clang-tidy file --- .clang-tidy | 1 - src/bar-exif.cc | 2 +- src/color-man.cc | 2 +- src/dupe.cc | 4 ++-- src/editors.cc | 2 +- src/exiv2.cc | 2 +- src/filedata.cc | 10 +++++----- src/image-load-webp.cc | 12 ++++++------ src/metadata.cc | 2 +- src/ui-misc.cc | 4 ++-- src/ui-pathsel.cc | 2 +- src/view-dir.cc | 2 +- src/view-file/view-file-icon.cc | 2 +- 13 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 255a1729..6d3a2a7b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -43,7 +43,6 @@ Checks: > -modernize-avoid-c-arrays, -modernize-macro-to-enum, -modernize-raw-string-literal, - -modernize-use-auto, -modernize-use-trailing-return-type, -performance-no-int-to-ptr, -readability-braces-around-statements, diff --git a/src/bar-exif.cc b/src/bar-exif.cc index 4c10ea45..0eaf5f7d 100644 --- a/src/bar-exif.cc +++ b/src/bar-exif.cc @@ -807,7 +807,7 @@ static void bar_pane_exif_destroy(GtkWidget *, gpointer data) #pragma GCC diagnostic ignored "-Wunused-function" static void bar_pane_exif_size_request_unused(GtkWidget *, GtkRequisition *requisition, gpointer data) { - PaneExifData *ped = static_cast(data); + auto *ped = static_cast(data); if (requisition->height < ped->min_height) { requisition->height = ped->min_height; diff --git a/src/color-man.cc b/src/color-man.cc index 5efea3dd..e9be69bd 100644 --- a/src/color-man.cc +++ b/src/color-man.cc @@ -343,7 +343,7 @@ void color_man_correct_region(ColorMan *cm, GdkPixbuf *pixbuf, gint x, gint y, g #pragma GCC diagnostic ignored "-Wunused-function" static gboolean color_man_idle_cb_unused(gpointer data) { - ColorMan *cm = static_cast(data); + auto *cm = static_cast(data); gint width, height; gint rh; diff --git a/src/dupe.cc b/src/dupe.cc index 7da7d98d..71373479 100644 --- a/src/dupe.cc +++ b/src/dupe.cc @@ -474,7 +474,7 @@ static DupeItem *dupe_item_find_fd_by_list_unused(FileData *fd, GList *work) { while (work) { - DupeItem *di = static_cast(work->data); + auto *di = static_cast(work->data); if (di->fd == fd) return di; @@ -498,7 +498,7 @@ static DupeItem *dupe_item_find_path_by_list_unused(const gchar *path, GList *wo { while (work) { - DupeItem *di = static_cast(work->data); + auto *di = static_cast(work->data); if (strcmp(di->fd->path, path) == 0) return di; diff --git a/src/editors.cc b/src/editors.cc index 3d47382f..58a8e026 100644 --- a/src/editors.cc +++ b/src/editors.cc @@ -1439,7 +1439,7 @@ const gchar *editor_get_error_str(EditorFlags flags) #pragma GCC diagnostic ignored "-Wunused-function" const gchar *editor_get_name_unused(const gchar *key) { - EditorDescription *editor = static_cast(g_hash_table_lookup(editors, key)); + auto *editor = static_cast(g_hash_table_lookup(editors, key)); if (!editor) return nullptr; diff --git a/src/exiv2.cc b/src/exiv2.cc index 07230703..e16d89b7 100644 --- a/src/exiv2.cc +++ b/src/exiv2.cc @@ -1222,7 +1222,7 @@ guchar *exif_get_preview(ExifData *exif, guint *data_len, gint requested_width, // Let's not touch data_len until we finish copy. // Just in case we run into OOM. size_t img_sz = image.size(); - Exiv2::byte* b = new Exiv2::byte[img_sz]; + auto* b = new Exiv2::byte[img_sz]; std::copy_n(image.pData(), img_sz, b); *data_len = img_sz; return b; diff --git a/src/filedata.cc b/src/filedata.cc index 5a73a10c..c990c27c 100644 --- a/src/filedata.cc +++ b/src/filedata.cc @@ -586,7 +586,7 @@ void set_exif_time_data_unused(GList *files) while (files) { - FileData *file = static_cast(files->data); + auto *file = static_cast(files->data); read_exif_time_data(file); files = files->next; @@ -599,7 +599,7 @@ void set_exif_time_digitized_data_unused(GList *files) while (files) { - FileData *file = static_cast(files->data); + auto *file = static_cast(files->data); read_exif_time_digitized_data(file); files = files->next; @@ -613,7 +613,7 @@ void set_rating_data_unused(GList *files) while (files) { - FileData *file = static_cast(files->data); + auto *file = static_cast(files->data); rating_str = metadata_read_string(file, RATING_KEY, METADATA_PLAIN); if (rating_str ) { @@ -3236,12 +3236,12 @@ gboolean file_data_unregister_notify_func(FileDataNotifyFunc func, gpointer data #pragma GCC diagnostic ignored "-Wunused-function" gboolean file_data_send_notification_idle_cb_unused(gpointer data) { - NotifyIdleData *nid = (NotifyIdleData *)data; + auto *nid = (NotifyIdleData *)data; GList *work = notify_func_list; while (work) { - NotifyData *nd = (NotifyData *)work->data; + auto *nd = (NotifyData *)work->data; nd->func(nid->fd, nid->type, nd->data); work = work->next; diff --git a/src/image-load-webp.cc b/src/image-load-webp.cc index 111169f7..3756f12f 100644 --- a/src/image-load-webp.cc +++ b/src/image-load-webp.cc @@ -45,7 +45,7 @@ static void free_buffer(guchar *pixels, gpointer) static gboolean image_loader_webp_load(gpointer loader, const guchar *buf, gsize count, GError **) { - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; + auto *ld = (ImageLoaderWEBP *) loader; guint8* data; gint width, height; gboolean res_info; @@ -84,7 +84,7 @@ static gboolean image_loader_webp_load(gpointer loader, const guchar *buf, gsize static gpointer image_loader_webp_new(ImageLoaderBackendCbAreaUpdated area_updated_cb, ImageLoaderBackendCbSize size_cb, ImageLoaderBackendCbAreaPrepared area_prepared_cb, gpointer data) { - ImageLoaderWEBP *loader = g_new0(ImageLoaderWEBP, 1); + auto *loader = g_new0(ImageLoaderWEBP, 1); loader->area_updated_cb = area_updated_cb; loader->size_cb = size_cb; loader->area_prepared_cb = area_prepared_cb; @@ -95,14 +95,14 @@ static gpointer image_loader_webp_new(ImageLoaderBackendCbAreaUpdated area_updat static void image_loader_webp_set_size(gpointer loader, int width, int height) { - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; + auto *ld = (ImageLoaderWEBP *) loader; ld->requested_width = width; ld->requested_height = height; } static GdkPixbuf* image_loader_webp_get_pixbuf(gpointer loader) { - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; + auto *ld = (ImageLoaderWEBP *) loader; return ld->pixbuf; } @@ -124,13 +124,13 @@ static gboolean image_loader_webp_close(gpointer, GError **) static void image_loader_webp_abort(gpointer loader) { - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; + auto *ld = (ImageLoaderWEBP *) loader; ld->abort = TRUE; } static void image_loader_webp_free(gpointer loader) { - ImageLoaderWEBP *ld = (ImageLoaderWEBP *) loader; + auto *ld = (ImageLoaderWEBP *) loader; if (ld->pixbuf) g_object_unref(ld->pixbuf); g_free(ld); } diff --git a/src/metadata.cc b/src/metadata.cc index 388a49e1..84f319fe 100644 --- a/src/metadata.cc +++ b/src/metadata.cc @@ -235,7 +235,7 @@ gboolean metadata_write_queue_remove_list_unused(GList *list) work = list; while (work) { - FileData *fd = static_cast(work->data); + auto *fd = static_cast(work->data); work = work->next; ret = ret && metadata_write_queue_remove(fd); } diff --git a/src/ui-misc.cc b/src/ui-misc.cc index d8140301..771d3b0f 100644 --- a/src/ui-misc.cc +++ b/src/ui-misc.cc @@ -337,7 +337,7 @@ void pref_checkbox_link_sensitivity(GtkWidget *button, GtkWidget *widget) #pragma GCC diagnostic ignored "-Wunused-function" static void pref_checkbox_link_sensitivity_swap_cb_unused(GtkWidget *button, gpointer data) { - GtkWidget *widget = static_cast(data); + auto *widget = static_cast(data); gtk_widget_set_sensitive(widget, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))); } @@ -423,7 +423,7 @@ GtkWidget *pref_radiobutton_new_mnemonic_unused(GtkWidget *parent_box, GtkWidget static void pref_radiobutton_int_cb_unused(GtkWidget *widget, gpointer data) { - gboolean *result = static_cast(data); + auto *result = static_cast(data); if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { diff --git a/src/ui-pathsel.cc b/src/ui-pathsel.cc index 29a308bf..1fdf999c 100644 --- a/src/ui-pathsel.cc +++ b/src/ui-pathsel.cc @@ -1215,7 +1215,7 @@ GtkWidget *path_selection_new_unused(const gchar *path, GtkWidget *entry) void path_selection_sync_to_entry_unused(GtkWidget *entry) { - Dest_Data *dd = static_cast(g_object_get_data(G_OBJECT(entry), "destination_data")); + auto *dd = static_cast(g_object_get_data(G_OBJECT(entry), "destination_data")); const gchar *path; if (!dd) return; diff --git a/src/view-dir.cc b/src/view-dir.cc index dbe89b55..28fd9ceb 100644 --- a/src/view-dir.cc +++ b/src/view-dir.cc @@ -1143,7 +1143,7 @@ void vd_dnd_init(ViewDir *vd) #pragma GCC diagnostic ignored "-Wunused-function" void vd_menu_position_cb_unused(GtkMenu *menu, gint *x, gint *y, gboolean *, gpointer data) { - ViewDir *vd = static_cast(data); + auto *vd = static_cast(data); GtkTreeModel *store; GtkTreeIter iter; GtkTreePath *tpath; diff --git a/src/view-file/view-file-icon.cc b/src/view-file/view-file-icon.cc index 931f67cd..8fc272f8 100644 --- a/src/view-file/view-file-icon.cc +++ b/src/view-file/view-file-icon.cc @@ -808,7 +808,7 @@ static void vficon_select_region_util(ViewFile *vf, FileData *start, FileData *e #pragma GCC diagnostic ignored "-Wunused-function" gboolean vficon_index_is_selected_unused(ViewFile *vf, gint row) { - FileData *fd = static_cast(g_list_nth_data(vf->list, row)); + auto *fd = static_cast(g_list_nth_data(vf->list, row)); if (!fd) return FALSE; -- 2.20.1