clang-tidy: modernize-use-auto
authorColin Clark <colin.clark@cclark.uk>
Fri, 2 Feb 2024 16:34:35 +0000 (16:34 +0000)
committerColin Clark <colin.clark@cclark.uk>
Fri, 2 Feb 2024 16:34:35 +0000 (16:34 +0000)
- Fix warnings identified by this flag
- Remove the exclude from .clang-tidy file

13 files changed:
.clang-tidy
src/bar-exif.cc
src/color-man.cc
src/dupe.cc
src/editors.cc
src/exiv2.cc
src/filedata.cc
src/image-load-webp.cc
src/metadata.cc
src/ui-misc.cc
src/ui-pathsel.cc
src/view-dir.cc
src/view-file/view-file-icon.cc

index 255a172..6d3a2a7 100644 (file)
@@ -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,
index 4c10ea4..0eaf5f7 100644 (file)
@@ -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<PaneExifData *>(data);
+       auto *ped = static_cast<PaneExifData *>(data);
        if (requisition->height < ped->min_height)
                {
                requisition->height = ped->min_height;
index 5efea3d..e9be69b 100644 (file)
@@ -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<ColorMan *>(data);
+       auto *cm = static_cast<ColorMan *>(data);
        gint width, height;
        gint rh;
 
index 7da7d98..7137347 100644 (file)
@@ -474,7 +474,7 @@ static DupeItem *dupe_item_find_fd_by_list_unused(FileData *fd, GList *work)
 {
        while (work)
                {
-               DupeItem *di = static_cast<DupeItem *>(work->data);
+               auto *di = static_cast<DupeItem *>(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<DupeItem *>(work->data);
+               auto *di = static_cast<DupeItem *>(work->data);
 
                if (strcmp(di->fd->path, path) == 0) return di;
 
index 3d47382..58a8e02 100644 (file)
@@ -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<EditorDescription *>(g_hash_table_lookup(editors, key));
+       auto *editor = static_cast<EditorDescription *>(g_hash_table_lookup(editors, key));
 
        if (!editor) return nullptr;
 
index 0723070..e16d89b 100644 (file)
@@ -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;
index 5a73a10..c990c27 100644 (file)
@@ -586,7 +586,7 @@ void set_exif_time_data_unused(GList *files)
 
        while (files)
                {
-               FileData *file = static_cast<FileData *>(files->data);
+               auto *file = static_cast<FileData *>(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<FileData *>(files->data);
+               auto *file = static_cast<FileData *>(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<FileData *>(files->data);
+               auto *file = static_cast<FileData *>(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;
index 111169f..3756f12 100644 (file)
@@ -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);
 }
index 388a49e..84f319f 100644 (file)
@@ -235,7 +235,7 @@ gboolean metadata_write_queue_remove_list_unused(GList *list)
        work = list;
        while (work)
                {
-               FileData *fd = static_cast<FileData *>(work->data);
+               auto *fd = static_cast<FileData *>(work->data);
                work = work->next;
                ret = ret && metadata_write_queue_remove(fd);
                }
index d814030..771d3b0 100644 (file)
@@ -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<GtkWidget *>(data);
+       auto *widget = static_cast<GtkWidget *>(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<gboolean *>(data);
+       auto *result = static_cast<gboolean *>(data);
 
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
                {
index 29a308b..1fdf999 100644 (file)
@@ -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<Dest_Data *>(g_object_get_data(G_OBJECT(entry), "destination_data"));
+       auto *dd = static_cast<Dest_Data *>(g_object_get_data(G_OBJECT(entry), "destination_data"));
        const gchar *path;
 
        if (!dd) return;
index dbe89b5..28fd9ce 100644 (file)
@@ -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<ViewDir *>(data);
+       auto *vd = static_cast<ViewDir *>(data);
        GtkTreeModel *store;
        GtkTreeIter iter;
        GtkTreePath *tpath;
index 931f67c..8fc272f 100644 (file)
@@ -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<FileData *>(g_list_nth_data(vf->list, row));
+       auto *fd = static_cast<FileData *>(g_list_nth_data(vf->list, row));
 
        if (!fd) return FALSE;