manual fixes for C casts
authorRosen Penev <rosenp@gmail.com>
Mon, 5 Jun 2023 09:05:06 +0000 (02:05 -0700)
committerColin Clark <colin.clark@cclark.uk>
Thu, 8 Jun 2023 12:18:25 +0000 (13:18 +0100)
clang-tidy does not fix these as they require both const and
reinterpret_cast.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
35 files changed:
src/advanced-exif.cc
src/bar-exif.cc
src/bar-keywords.cc
src/collect-table.cc
src/debug.cc
src/dupe.cc
src/filedata.cc
src/filefilter.cc
src/image-load-collection.cc
src/image-load-cr3.cc
src/image-load-dds.cc
src/image-load-external.cc
src/image-load-ffmpegthumbnailer.cc
src/image-load-gdk.cc
src/image-load-jpeg.cc
src/image-load-psd.cc
src/image-load-svgz.cc
src/image-load-zxscr.cc
src/image-load.cc
src/image.cc
src/img-view.cc
src/jpeg-parser.cc
src/layout-image.cc
src/layout-util.cc
src/main.cc
src/md5-util.cc
src/metadata.cc
src/osd.cc
src/preferences.cc
src/print.cc
src/thumb-standard.cc
src/toolbar.cc
src/ui-bookmark.cc
src/ui-tabcomp.cc
src/utilops.cc

index 02f2696..250d95a 100644 (file)
@@ -354,7 +354,7 @@ static gboolean advanced_exif_mouseclick(GtkWidget *UNUSED(widget),
                gtk_tree_model_get_iter(store, &iter, path);
 
                cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(ew->listview));
-               col_num = g_list_index(cols, (gpointer)column);
+               col_num = g_list_index(cols, column);
                gtk_tree_model_get(store, &iter, display_order[col_num], &value, -1);
 
                clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
index 7c060ed..fe4ddeb 100644 (file)
@@ -397,7 +397,7 @@ static void bar_pane_exif_dnd_receive(GtkWidget *pane, GdkDragContext *UNUSED(co
                        break;
                default:
                        /** @FIXME this needs a check for valid exif keys */
-                       new_entry = bar_pane_exif_add_entry(ped, (gchar *)gtk_selection_data_get_data(selection_data), NULL, TRUE, FALSE);
+                       new_entry = bar_pane_exif_add_entry(ped, reinterpret_cast<const gchar *>(gtk_selection_data_get_data(selection_data)), NULL, TRUE, FALSE);
                        break;
                }
 
index c70ec7a..51324c2 100644 (file)
@@ -686,7 +686,7 @@ static void bar_pane_keywords_dnd_receive(GtkWidget *tree_view, GdkDragContext *
                        break;
                        }
                default:
-                       new_keywords = string_to_keywords_list((gchar *)gtk_selection_data_get_data(selection_data));
+                       new_keywords = string_to_keywords_list(reinterpret_cast<const gchar *>(gtk_selection_data_get_data(selection_data)));
                        break;
                }
 
index a81f63a..9538730 100644 (file)
@@ -2334,7 +2334,7 @@ static void collection_table_dnd_receive(GtkWidget *UNUSED(widget), GdkDragConte
        switch (info)
                {
                case TARGET_APP_COLLECTION_MEMBER:
-                       source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list);
+                       source = collection_from_dnd_data(reinterpret_cast<const gchar *>(gtk_selection_data_get_data(selection_data)), &list, &info_list);
                        if (source)
                                {
                                if (source == ct->cd)
index b3e176f..ae5f692 100644 (file)
@@ -49,7 +49,7 @@ static gboolean log_msg_cb(gpointer data)
  * @brief Appends a user information message to the log window queue
  * @param data The message
  * @returns FALSE
- * 
+ *
  * If the first word of the message is either "error" or "warning"
  * (case insensitive) the message is color-coded appropriately
  */
@@ -259,10 +259,10 @@ gchar *get_regexp(void)
 #ifdef HAVE_EXECINFO_H
 /**
  * @brief Backtrace of geeqie files
- * @param file 
- * @param function 
- * @param line 
- * 
+ * @param file
+ * @param function
+ * @param line
+ *
  * Requires command line program addr2line \n
  * Prints the contents of the backtrace buffer for Geeqie files. \n
  * Format printed is: \n
@@ -286,7 +286,7 @@ void log_print_backtrace(const gchar *file, const gchar *function, gint line)
        gint i;
        void *bt[1024];
 
-       if (runcmd((gchar *)"which addr2line >/dev/null 2>&1") == 0)
+       if (runcmd(reinterpret_cast<const gchar *>("which addr2line >/dev/null 2>&1")) == 0)
                {
                exe_path = g_path_get_dirname(gq_executable_path);
                bt_size = backtrace(bt, 1024);
@@ -352,10 +352,10 @@ void log_print_backtrace(const gchar *file, const gchar *function, gint line)
 
 /**
  * @brief Print ref. count and image name
- * @param file 
- * @param function 
- * @param line 
- * 
+ * @param file
+ * @param function
+ * @param line
+ *
  * Print image ref. count and full path name of all images in
  * the file_data_pool.
  */
index 99a666f..8a37be5 100644 (file)
@@ -1337,8 +1337,8 @@ static GList *dupe_match_group_trim(GList *list, DupeWindow *dw)
 
 static gint dupe_match_sort_groups_cb(gconstpointer a, gconstpointer b)
 {
-       auto da = (DupeMatch *)a;
-       auto db = (DupeMatch *)b;
+       auto da = static_cast<const DupeMatch *>(a);
+       auto db = static_cast<const DupeMatch *>(b);
 
        if (da->rank > db->rank) return -1;
        if (da->rank < db->rank) return 1;
@@ -1366,8 +1366,8 @@ static void dupe_match_sort_groups(GList *list)
 
 static gint dupe_match_totals_sort_cb(gconstpointer a, gconstpointer b)
 {
-       auto da = (DupeItem *)a;
-       auto db = (DupeItem *)b;
+       auto da = static_cast<const DupeItem *>(a);
+       auto db = static_cast<const DupeItem *>(b);
 
        if (g_list_length(da->group) > g_list_length(db->group)) return -1;
        if (g_list_length(da->group) < g_list_length(db->group)) return 1;
@@ -1388,8 +1388,8 @@ static gint dupe_match_totals_sort_cb(gconstpointer a, gconstpointer b)
  */
 static gint dupe_match_rank_sort_cb(gconstpointer a, gconstpointer b)
 {
-       auto da = (DupeItem *)a;
-       auto db = (DupeItem *)b;
+       auto da = static_cast<const DupeItem *>(a);
+       auto db = static_cast<const DupeItem *>(b);
 
        if (da->group_rank > db->group_rank) return -1;
        if (da->group_rank < db->group_rank) return 1;
@@ -2409,7 +2409,7 @@ static gboolean create_checksums_dimensions(DupeWindow *dw, GList *list)
  */
 static gint sort_func(gconstpointer a, gconstpointer b)
 {
-       return (((DupeSearchMatch *)a)->index - ((DupeSearchMatch *)b)->index);
+       return static_cast<const DupeSearchMatch *>(a)->index - static_cast<const DupeSearchMatch *>(b)->index;
 }
 
 /**
@@ -5003,7 +5003,7 @@ static void dupe_dnd_data_get(GtkWidget *widget, GdkDragContext *context,
        switch (info)
                {
                case TARGET_APP_COLLECTION_MEMBER:
-                       collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, NULL);
+                       collection_from_dnd_data(reinterpret_cast<const gchar *>(gtk_selection_data_get_data(selection_data)), &list, NULL);
                        break;
                case TARGET_URI_LIST:
                        list = uri_filelist_from_gtk_selection_data(selection_data);
index 217e9c7..641b6d4 100644 (file)
@@ -3172,8 +3172,8 @@ static GList *notify_func_list = NULL;
 
 static gint file_data_notify_sort(gconstpointer a, gconstpointer b)
 {
-       auto nda = (NotifyData *)a;
-       auto ndb = (NotifyData *)b;
+       auto nda = static_cast<const NotifyData *>(a);
+       auto ndb = static_cast<const NotifyData *>(b);
 
        if (nda->priority < ndb->priority) return -1;
        if (nda->priority > ndb->priority) return 1;
index 4a501bb..e5b0d5b 100644 (file)
@@ -358,8 +358,8 @@ GList *filter_to_list(const gchar *extensions)
 
 static gint filter_sort_ext_len_cb(gconstpointer a, gconstpointer b)
 {
-       auto sa = (gchar *)a;
-       auto sb = (gchar *)b;
+       auto sa = static_cast<const gchar *>(a);
+       auto sb = static_cast<const gchar *>(b);
 
        gint len_a = strlen(sa);
        gint len_b = strlen(sb);
index 491864f..34d7550 100644 (file)
@@ -121,7 +121,7 @@ static gpointer image_loader_collection_new(ImageLoaderBackendCbAreaUpdated area
        loader->size_cb = size_cb;
        loader->area_prepared_cb = area_prepared_cb;
        loader->data = data;
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_collection_set_size(gpointer loader, int width, int height)
index af2c412..5760a53 100644 (file)
@@ -135,7 +135,7 @@ static gpointer image_loader_cr3_new(ImageLoaderBackendCbAreaUpdated area_update
        loader->size_cb = size_cb;
        loader->area_prepared_cb = area_prepared_cb;
        loader->data = data;
-       return (gpointer) loader;
+       return loader;
 }
 
 static void
index 03a7b9a..e172a95 100644 (file)
@@ -565,7 +565,7 @@ static gpointer image_loader_dds_new(ImageLoaderBackendCbAreaUpdated area_update
        loader->size_cb = size_cb;
        loader->area_prepared_cb = area_prepared_cb;
        loader->data = data;
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_dds_set_size(gpointer loader, int width, int height)
index abed18d..21e7e70 100644 (file)
@@ -74,7 +74,7 @@ static gpointer image_loader_external_new(ImageLoaderBackendCbAreaUpdated area_u
        loader->size_cb = size_cb;
        loader->area_prepared_cb = area_prepared_cb;
        loader->data = data;
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_external_set_size(gpointer loader, int width, int height)
index bdff641..c65eca6 100644 (file)
@@ -86,7 +86,7 @@ static gpointer image_loader_ft_new(ImageLoaderBackendCbAreaUpdated area_updated
        video_thumbnailer_set_log_callback(loader->vt, image_loader_ft_log_cb);
 #endif
 
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_ft_set_size(gpointer loader, int width, int height)
index 3ee5efc..d51c2d4 100644 (file)
@@ -50,7 +50,7 @@ static gpointer image_loader_gdk_new(ImageLoaderBackendCbAreaUpdated area_update
        g_signal_connect(G_OBJECT(loader), "area_updated", G_CALLBACK(area_updated_cb), data);
        g_signal_connect(G_OBJECT(loader), "size_prepared", G_CALLBACK(size_cb), data);
        g_signal_connect(G_OBJECT(loader), "area_prepared", G_CALLBACK(area_prepared_cb), data);
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_gdk_abort(gpointer UNUSED(loader))
index e2d54d4..70a8ef3 100644 (file)
@@ -138,7 +138,7 @@ static gpointer image_loader_jpeg_new(ImageLoaderBackendCbAreaUpdated area_updat
        loader->size_cb = size_cb;
        loader->area_prepared_cb = area_prepared_cb;
        loader->data = data;
-       return (gpointer) loader;
+       return loader;
 }
 
 static void
index 5fa3251..a27e482 100644 (file)
@@ -17,9 +17,9 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * 
+ *
  * Derived from:
- * 
+ *
  * GdkPixbuf library - PSD image loader
  *
  * Copyright (C) 2008 Jan Dudek
@@ -112,7 +112,7 @@ typedef enum
 typedef struct
 {
        PsdReadState       state;
-       
+
        GdkPixbuf*                  pixbuf;
        gpointer                    user_data;
 
@@ -160,7 +160,7 @@ static PsdHeader
 psd_parse_header (guchar* str)
 {
        PsdHeader hd;
-       
+
        memcpy(hd.signature, str, 4);
        hd.version = read_uint16(str + 4);
        hd.channels = read_uint16(str + 12);
@@ -237,12 +237,12 @@ decompress_line(const guchar* src, guint line_length, guchar* dest)
        while (bytes_read < line_length) {
                gchar byte = src[bytes_read];
                ++bytes_read;
-       
+
                if (byte == -128) {
                        continue;
                } else if (byte > -1) {
                        gint count = byte + 1;
-               
+
                        /* copy next count bytes */
                        for (k = 0; k < count; ++k) {
                                *dest = src[bytes_read];
@@ -251,10 +251,10 @@ decompress_line(const guchar* src, guint line_length, guchar* dest)
                        }
                } else {
                        gint count = -byte + 1;
-               
+
                        /* copy next byte count times */
                        guchar next_byte = src[bytes_read];
-                       ++bytes_read; 
+                       ++bytes_read;
                        for (k = 0; k < count; ++k) {
                                *dest = next_byte;
                                ++dest;
@@ -320,7 +320,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                        ctx->depth = hd.depth;
                                        ctx->depth_bytes = (ctx->depth/8 > 0 ? ctx->depth/8 : 1);
                                        ctx->color_mode = static_cast<PsdColorMode>(hd.color_mode);
-                                       
+
                                        if (ctx->color_mode != PSD_MODE_RGB
                                            && ctx->color_mode != PSD_MODE_GRAYSCALE
                                            && ctx->color_mode != PSD_MODE_CMYK
@@ -330,7 +330,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                                free_context(ctx);
                                                return FALSE;
                                        }
-                                       
+
                                        if (ctx->depth != 8 && ctx->depth != 16) {
                                                log_printf("warning: psd - Unsupported color depth\n");
                                                free_context(ctx);
@@ -341,11 +341,11 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                           row in RLE compressed format. 2*width should be enough */
                                        g_free(ctx->buffer);
                                        ctx->buffer = static_cast<guchar *>(g_malloc(ctx->width * 2 * ctx->depth_bytes));
-                                       
+
                                        /* this will be needed for RLE decompression */
                                        ctx->lines_lengths =
                                                static_cast<guint16 *>(g_malloc(2 * ctx->channels * ctx->height));
-                                       
+
                                        ctx->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
                                                FALSE, 8, ctx->width, ctx->height);
 
@@ -356,7 +356,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                                free_context(ctx);
                                                return FALSE;
                                        }
-                                       
+
                                        /* create separate buffers for each channel */
                                        ctx->ch_bufs = static_cast<guchar **>(g_malloc(sizeof(guchar*) * ctx->channels));
                                        for (i = 0; i < ctx->channels; i++) {
@@ -367,7 +367,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                                log_printf("warning: Insufficient memory to load PSD image file\n");
                                                free_context(ctx);
                                                return FALSE;
-                                               }       
+                                               }
                                        }
 
                                        ctx->state = PSD_STATE_COLOR_MODE_BLOCK;
@@ -430,7 +430,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                                line_length = ctx->lines_lengths[
                                                        ctx->curr_ch * ctx->height + ctx->curr_row];
                                        }
-                                       
+
                                        if (feed_buffer(ctx->buffer, &ctx->bytes_read, &buf, &size,
                                                        line_length))
                                        {
@@ -442,10 +442,10 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                                        memcpy(ctx->ch_bufs[ctx->curr_ch] + ctx->pos,
                                                                ctx->buffer, line_length);
                                                }
-                                               
+
                                                ctx->pos += ctx->width * ctx->depth_bytes;
                                                ++ctx->curr_row;
-                                       
+
                                                if (ctx->curr_row >= ctx->height) {
                                                        ++ctx->curr_ch;
                                                        ctx->curr_row = 0;
@@ -454,7 +454,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                                                ctx->state = PSD_STATE_DONE;
                                                        }
                                                }
-                                               
+
                                                reset_context_buffer(ctx);
                                        }
                                }
@@ -465,7 +465,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                break;
                }
        }
-       
+
        if (ctx->state == PSD_STATE_DONE && !ctx->finalized) {
                /* convert or copy channel buffers to our GdkPixbuf */
                guchar* pixels = gdk_pixbuf_get_pixels(ctx->pixbuf);
@@ -493,7 +493,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                } else if (ctx->color_mode == PSD_MODE_CMYK) {
                        /* unfortunately, this doesn't work 100% correctly...
                           CMYK-RGB conversion distorts colors significantly  */
-               
+
                        guchar* pixels = gdk_pixbuf_get_pixels(ctx->pixbuf);
                        for (i = 0; i < ctx->height; i++) {
                                for (j = 0; j < ctx->width; j++) {
@@ -505,7 +505,7 @@ static gboolean image_loader_psd_load(gpointer loader, const guchar *buf, gsize
                                                static_cast<double>(ctx->ch_bufs[2][ctx->width*i + j]) / 255.0;
                                        double k = 1.0 -
                                                static_cast<double>(ctx->ch_bufs[3][ctx->width*i + j]) / 255.0;
-                                       
+
                                        pixels[3*j+0] = (1.0 - (c * (1.0 - k) + k)) * 255.0;
                                        pixels[3*j+1] = (1.0 - (m * (1.0 - k) + k)) * 255.0;
                                        pixels[3*j+2] = (1.0 - (y * (1.0 - k) + k)) * 255.0;
@@ -534,7 +534,7 @@ static gpointer image_loader_psd_new(ImageLoaderBackendCbAreaUpdated area_update
        loader->size_cb = size_cb;
        loader->area_prepared_cb = area_prepared_cb;
        loader->data = data;
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_psd_set_size(gpointer loader, int width, int height)
index dea214b..eaa806d 100644 (file)
@@ -48,7 +48,7 @@ static gpointer image_loader_svgz_new(ImageLoaderBackendCbAreaUpdated area_updat
        g_signal_connect(G_OBJECT(loader), "area_updated", G_CALLBACK(area_updated_cb), data);
        g_signal_connect(G_OBJECT(loader), "size_prepared", G_CALLBACK(size_cb), data);
        g_signal_connect(G_OBJECT(loader), "area_prepared", G_CALLBACK(area_prepared_cb), data);
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_svgz_abort(gpointer UNUSED(loader))
index 2fa69b3..aad5879 100644 (file)
@@ -151,7 +151,7 @@ static gpointer image_loader_zxscr_new(ImageLoaderBackendCbAreaUpdated area_upda
        loader->size_cb = size_cb;
        loader->area_prepared_cb = area_prepared_cb;
        loader->data = data;
-       return (gpointer) loader;
+       return loader;
 }
 
 static void image_loader_zxscr_set_size(gpointer loader, int width, int height)
index d27bab5..df1a603 100644 (file)
@@ -989,7 +989,7 @@ static gboolean image_loader_setup_source(ImageLoader *il)
 
                if (options->thumbnails.use_exif)
                        {
-                       il->mapped_file = exif_get_preview(exif, static_cast<guint *>(&il->bytes_total), il->requested_width, il->requested_height);
+                       il->mapped_file = exif_get_preview(exif, reinterpret_cast<guint *>(&il->bytes_total), il->requested_width, il->requested_height);
 
                        if (il->mapped_file)
                                {
@@ -998,7 +998,7 @@ static gboolean image_loader_setup_source(ImageLoader *il)
                        }
                else
                        {
-                       il->mapped_file = libraw_get_preview(il, static_cast<guint *>(&il->bytes_total));
+                       il->mapped_file = libraw_get_preview(il, reinterpret_cast<guint *>(&il->bytes_total));
 
                        if (il->mapped_file)
                                {
@@ -1018,7 +1018,7 @@ static gboolean image_loader_setup_source(ImageLoader *il)
                /* If libraw does not find a thumbnail, try exiv2 */
                if (!il->mapped_file)
                        {
-                       il->mapped_file = exif_get_preview(exif, static_cast<guint *>(&il->bytes_total), 0, 0); /* get the largest available preview image or NULL for normal images*/
+                       il->mapped_file = exif_get_preview(exif, reinterpret_cast<guint *>(&il->bytes_total), 0, 0); /* get the largest available preview image or NULL for normal images*/
 
                        if (il->mapped_file)
                                {
index 1b6ed77..a6268c8 100644 (file)
@@ -552,7 +552,7 @@ static gboolean image_post_process_color(ImageWindow *imd, gint start_row, gbool
                        cm->incremental_sync = TRUE;
                        }
 
-               imd->cm = (gpointer)cm;
+               imd->cm = cm;
                }
 
        image_update_util(imd);
@@ -685,7 +685,7 @@ void image_set_desaturate(ImageWindow *imd, gboolean desaturate)
 {
        imd->desaturate = desaturate;
        if (imd->cm || imd->desaturate || imd->overunderexposed)
-               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
+               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, imd, (imd->cm != NULL) );
        else
                pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), NULL, NULL, TRUE);
        pixbuf_renderer_set_orientation(reinterpret_cast<PixbufRenderer *>(imd->pr), imd->orientation);
@@ -700,7 +700,7 @@ void image_set_overunderexposed(ImageWindow *imd, gboolean overunderexposed)
 {
        imd->overunderexposed = overunderexposed;
        if (imd->cm || imd->desaturate || imd->overunderexposed)
-               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
+               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, imd, (imd->cm != NULL) );
        else
                pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), NULL, NULL, TRUE);
        pixbuf_renderer_set_orientation(reinterpret_cast<PixbufRenderer *>(imd->pr), imd->orientation);
@@ -1459,7 +1459,7 @@ void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboo
                }
 
        if (imd->cm || imd->desaturate || imd->overunderexposed)
-               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
+               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, imd, (imd->cm != NULL) );
 
        image_state_set(imd, IMAGE_STATE_IMAGE);
 }
@@ -1582,7 +1582,7 @@ void image_move_from_image(ImageWindow *imd, ImageWindow *source)
        pixbuf_renderer_move(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
 
        if (imd->cm || imd->desaturate || imd->overunderexposed)
-               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
+               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, imd, (imd->cm != NULL) );
        else
                pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), NULL, NULL, TRUE);
 
@@ -1644,7 +1644,7 @@ void image_copy_from_image(ImageWindow *imd, ImageWindow *source)
        pixbuf_renderer_copy(PIXBUF_RENDERER(imd->pr), PIXBUF_RENDERER(source->pr));
 
        if (imd->cm || imd->desaturate || imd->overunderexposed)
-               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, (gpointer) imd, (imd->cm != NULL) );
+               pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), image_post_process_tile_color_cb, imd, (imd->cm != NULL) );
        else
                pixbuf_renderer_set_post_process_func(reinterpret_cast<PixbufRenderer *>(imd->pr), NULL, NULL, TRUE);
 
index 25eaaae..5a84e7b 100644 (file)
@@ -1657,7 +1657,7 @@ static void view_window_get_dnd_data(GtkWidget *UNUSED(widget), GdkDragContext *
                        }
                else
                        {
-                       source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list);
+                       source = collection_from_dnd_data(reinterpret_cast<const gchar *>(gtk_selection_data_get_data(selection_data)), &list, &info_list);
                        }
 
                if (list)
index b41a2ec..265ee20 100644 (file)
@@ -338,7 +338,7 @@ MPOData *jpeg_get_mpo_data(const guchar *data, guint size)
                mpo = g_new0(MPOData, 1);
                mpo->mpo_offset = seg_offset;
 
-               tiff_parse_IFD_table(data + seg_offset,  offset , seg_size, bo, &next_offset, mpo_parse_Index_IFD_entry, (gpointer)mpo);
+               tiff_parse_IFD_table(data + seg_offset,  offset , seg_size, bo, &next_offset, mpo_parse_Index_IFD_entry, mpo);
                if (!mpo->images) mpo->num_images = 0;
 
 
@@ -375,7 +375,7 @@ MPOData *jpeg_get_mpo_data(const guchar *data, guint size)
                                        }
 
                                }
-                       tiff_parse_IFD_table(data + mpo->images[i].offset + seg_offset,  offset , seg_size, bo, NULL, mpo_parse_Attributes_IFD_entry, (gpointer)&mpo->images[i]);
+                       tiff_parse_IFD_table(data + mpo->images[i].offset + seg_offset,  offset , seg_size, bo, NULL, mpo_parse_Attributes_IFD_entry, &mpo->images[i]);
                        }
 
                return mpo;
index cc9712a..785abf6 100644 (file)
@@ -909,7 +909,7 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *UNUSED(c
 
        if (info == TARGET_TEXT_PLAIN)
                {
-               url = g_strdup((gchar *)gtk_selection_data_get_data(selection_data));
+               url = g_strdup(reinterpret_cast<const gchar *>(gtk_selection_data_get_data(selection_data)));
                download_web_file(url, FALSE, lw);
                g_free(url);
                }
@@ -927,7 +927,7 @@ static void layout_image_dnd_receive(GtkWidget *widget, GdkDragContext *UNUSED(c
                        }
                else
                        {
-                       source = collection_from_dnd_data((gchar *)gtk_selection_data_get_data(selection_data), &list, &info_list);
+                       source = collection_from_dnd_data(reinterpret_cast<const gchar *>(gtk_selection_data_get_data(selection_data)), &list, &info_list);
                        }
 
                if (list)
index bcf571a..7a99146 100644 (file)
@@ -1278,8 +1278,8 @@ static void layout_menu_foreach_func(
        else
                key_name = g_strdup(name);
 
-       g_ptr_array_add(array, (gpointer)menu_name);
-       g_ptr_array_add(array, (gpointer)key_name);
+       g_ptr_array_add(array, menu_name);
+       g_ptr_array_add(array, key_name);
 
        g_free(name);
        g_free(path);
index 322f10d..a9be6d8 100644 (file)
@@ -946,7 +946,7 @@ static gboolean gq_accel_map_save(const gchar *path)
 
        g_string_free(gstring, TRUE);
 
-       gtk_accel_map_foreach((gpointer) ssi, gq_accel_map_print);
+       gtk_accel_map_foreach(ssi, gq_accel_map_print);
 
        if (secure_close(ssi))
                {
@@ -1139,7 +1139,7 @@ void exit_program(void)
  * This code is incorrect according to POSIX, because:
  *
  *   mmap is not async-signal-safe and thus may not be called from a signal handler
- * 
+ *
  *   mmap must be called with a valid file descriptor.  POSIX requires that
  *   a fildes argument of -1 must cause mmap to return EBADF.
  *
@@ -1229,7 +1229,7 @@ static gboolean theme_change_cb(GObject *UNUSED(gobject), GParamSpec *UNUSED(psp
 
 /**
  * @brief Set up the application paths
- * 
+ *
  * This function is required for use of AppImages. AppImages are
  * relocatable, and therefore cannot use fixed paths to various components.
  * These paths were originally #defines created during compilation.
index f608a57..a4d79db 100644 (file)
@@ -115,7 +115,7 @@ md5_update(MD5Context *ctx, const guchar *buf, guint32 len)
        /* Handle any leading odd-sized chunks */
 
        if (t) {
-               guchar *p = (guchar *) ctx->in + t;
+               auto p = (guchar *) ctx->in + t;
 
                t = 64 - t;
                if (len < t) {
index 94b0fe2..9566b2f 100644 (file)
@@ -655,7 +655,7 @@ static GList *remove_duplicate_strings_from_list(GList *list)
 
                if (g_hash_table_lookup(hashtable, key) == NULL)
                        {
-                       g_hash_table_insert(hashtable, (gpointer) key, GINT_TO_POINTER(1));
+                       g_hash_table_insert(hashtable, key, GINT_TO_POINTER(1));
                        newlist = g_list_prepend(newlist, key);
                        }
                work = work->next;
index 9d730d3..22f0688 100644 (file)
@@ -460,20 +460,20 @@ void osd_template_insert(GHashTable *vars, const gchar *keyword, const gchar *va
 {
        if (!value)
                {
-               g_hash_table_insert(vars, (gpointer)(keyword), static_cast<gpointer>(g_strdup("")));
+               g_hash_table_insert(vars, const_cast<gchar *>(keyword), g_strdup(""));
                return;
                }
 
        if (flags & OSDT_NO_DUP)
                {
-               g_hash_table_insert(vars, (gpointer)(keyword), (gpointer)value);
+               g_hash_table_insert(vars, const_cast<gchar *>(keyword), (gpointer)value);
                return;
                }
        else
                {
-               g_hash_table_insert(vars, (gpointer)(keyword), g_strdup(value));
+               g_hash_table_insert(vars, const_cast<gchar *>(keyword), g_strdup(value));
                }
 
-       if (flags & OSDT_FREE) g_free((gpointer) value);
+       if (flags & OSDT_FREE) g_free(const_cast<gchar *>(value));
 }
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index b4394c1..6d5c5f1 100644 (file)
@@ -1128,7 +1128,7 @@ static void add_video_menu(GtkWidget *table, gint column, gint row, const gchar
        pref_table_label(table, column, row, text, 0.0);
 
        combo = gtk_combo_box_text_new();
-       g_list_foreach(eds,video_menu_populate,(gpointer)combo);
+       g_list_foreach(eds,video_menu_populate,combo);
        current = option ? g_list_index(eds,g_hash_table_lookup(editors,option)): -1;
 
        gtk_combo_box_set_active(GTK_COMBO_BOX(combo), current);
@@ -3820,7 +3820,7 @@ static void config_tab_toolbar_status(GtkWidget *notebook)
 /* advanced tab */
 static gint extension_sort_cb(gconstpointer a, gconstpointer b)
 {
-       return g_strcmp0((gchar *)a, (gchar *)b);
+       return g_strcmp0(static_cast<const gchar *>(a), static_cast<const gchar *>(b));
 }
 
 static void config_tab_advanced(GtkWidget *notebook)
index 63b148d..4db0c31 100644 (file)
@@ -400,7 +400,7 @@ static void print_text_menu(GtkWidget *box, PrintWindow *pw)
        hbox = pref_box_new(subgroup, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
 
        button = pref_button_new(NULL, GTK_STOCK_SELECT_FONT, _("Font"), FALSE,
-                                G_CALLBACK(print_set_font_cb), (gpointer)"Image text font");
+                                G_CALLBACK(print_set_font_cb), const_cast<char *>("Image text font"));
 
        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
        gtk_widget_show(button);
@@ -454,7 +454,7 @@ static void print_text_menu(GtkWidget *box, PrintWindow *pw)
        hbox = pref_box_new(subgroup, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_BUTTON_GAP);
 
        button = pref_button_new(NULL, GTK_STOCK_SELECT_FONT, _("Font"), FALSE,
-                                G_CALLBACK(print_set_font_cb), (gpointer)"Page text font");
+                                G_CALLBACK(print_set_font_cb), const_cast<char *>("Page text font"));
 
        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
        gtk_widget_show(button);
index 48ef012..bb157ac 100644 (file)
@@ -35,7 +35,7 @@
 
 /**
  * @file
- * 
+ *
  * This thumbnail caching implementation attempts to conform
  * to the Thumbnail Managing Standard proposed on freedesktop.org
  * The standard is documented here: \n
@@ -143,7 +143,7 @@ static gchar *thumb_std_cache_path(const gchar *path, const gchar *uri, gboolean
 
        if (!path || !uri || !cache_subfolder) return NULL;
 
-       md5_get_digest((guchar *)uri, strlen(uri), digest);
+       md5_get_digest(reinterpret_cast<const guchar *>(uri), strlen(uri), digest);
        md5_text = md5_digest_to_text(digest);
 
        if (!md5_text) return NULL;
index e4e1230..1e03203 100644 (file)
@@ -261,9 +261,9 @@ static void toolbar_item_free(ToolbarButtonData *tbbd)
 {
        if (!tbbd) return;
 
-       g_free((gpointer)tbbd->name);
-       g_free((gpointer)tbbd->stock_id);
-       g_free((gpointer)tbbd);
+       g_free(const_cast<gchar *>(tbbd->name));
+       g_free(const_cast<gchar *>(tbbd->stock_id));
+       g_free(const_cast<ToolbarButtonData *>(tbbd));
 }
 
 static void toolbar_button_free(GtkWidget *widget)
index 57e43f8..16edc4c 100644 (file)
@@ -782,7 +782,7 @@ static void bookmark_list_destroy(GtkWidget *UNUSED(widget), gpointer data)
 
        bookmark_widget_list = g_list_remove(bookmark_widget_list, bm);
 
-       g_free((gpointer)bm->key);
+       g_free(const_cast<gchar *>(bm->key));
        g_free(bm);
 }
 
@@ -851,7 +851,7 @@ void bookmark_list_set_key(GtkWidget *list, const gchar *key)
 
        if (bm->key && strcmp(bm->key, key) == 0) return;
 
-       g_free((gpointer)bm->key);
+       g_free(const_cast<gchar *>(bm->key));
        bm->key = g_strdup(key);
 
        bookmark_populate(bm);
index abea694..e8260cd 100644 (file)
@@ -48,9 +48,9 @@
  * ----------------------------------------------------------------
  * Tab completion routines, can be connected to any gtkentry widget
  * using the tab_completion_add_to_entry() function.
- * 
+ *
  * Use remove_trailing_slash() to strip the trailing G_DIR_SEPARATOR.
- * 
+ *
  * ----------------------------------------------------------------
  */
 
@@ -253,7 +253,7 @@ static gboolean tab_completion_popup_key_press(GtkWidget *widget, GdkEventKey *e
 
                        /* Reduce the number of entries in the menu */
                        td->choices = 0;
-                       gtk_container_foreach(GTK_CONTAINER(widget), tab_completion_iter_menu_items, (gpointer) td);
+                       gtk_container_foreach(GTK_CONTAINER(widget), tab_completion_iter_menu_items, td);
                        if (td->choices > 1) return TRUE; /* multiple choices */
                        if (td->choices > 0) tab_completion_do(td); /* one choice */
                        }
index f117df5..9b818b5 100644 (file)
@@ -43,8 +43,8 @@ static GtkTargetEntry target_types[] =
 {
        {const_cast<gchar *>("text/plain"), 0, CLIPBOARD_TEXT_PLAIN},
        {const_cast<gchar *>("text/uri-list"), 0, CLIPBOARD_TEXT_URI_LIST},
-       {(gchar *)"x-special/gnome-copied-files", 0, CLIPBOARD_X_SPECIAL_GNOME_COPIED_FILES},
-       {(gchar *)"UTF8_STRING", 0, CLIPBOARD_UTF8_STRING}
+       {const_cast<gchar *>("x-special/gnome-copied-files"), 0, CLIPBOARD_X_SPECIAL_GNOME_COPIED_FILES},
+       {const_cast<gchar *>("UTF8_STRING"), 0, CLIPBOARD_UTF8_STRING},
 };
 static gint target_types_n = 4;