Fix c++ compiler wrnings
authorColin Clark <colin.clark@cclark.uk>
Fri, 7 Apr 2023 17:04:29 +0000 (18:04 +0100)
committerColin Clark <colin.clark@cclark.uk>
Fri, 7 Apr 2023 17:04:29 +0000 (18:04 +0100)
Most of the remaining warnings eliminated

17 files changed:
src/debug.cc
src/debug.h
src/dupe.cc
src/exif-common.cc
src/image-load.cc
src/layout-config.cc
src/logwindow.cc
src/main.cc
src/menu.cc
src/metadata.cc
src/pan-view/pan-util.cc
src/rcfile.cc
src/rcfile.h
src/ui-bookmark.cc
src/ui-misc.cc
src/ui-tabcomp.cc
src/view-file/view-file.cc

index 67b5781..e0d65df 100644 (file)
@@ -246,7 +246,7 @@ void init_exec_time(void)
        get_exec_time();
 }
 
-void set_regexp(gchar *cmd_regexp)
+void set_regexp(const gchar *cmd_regexp)
 {
        regexp = g_strdup(cmd_regexp);
 }
index 02883a1..e2c6677 100644 (file)
@@ -39,7 +39,7 @@ void log_print_backtrace(const gchar *file, const gchar *function_name, gint lin
 #define DEBUG_LEVEL_MIN 0
 #define DEBUG_LEVEL_MAX 4
 
-void set_regexp(gchar *regexp);
+void set_regexp(const gchar *regexp);
 gchar *get_regexp(void);
 gint get_debug_level(void);
 void set_debug_level(gint new_level);
index 741ddf9..788c0c7 100644 (file)
@@ -5321,7 +5321,7 @@ static void export_duplicates_data_save_cb(FileDialog *fdlg, gpointer data)
                output_string = g_string_append(output_string, sep);
                g_free(name);
 
-               output_string = g_string_append(output_string, g_strdup_printf("%"PRIu64, di->fd->size));
+               output_string = g_string_append(output_string, g_strdup_printf("%" PRIu64, di->fd->size));
                output_string = g_string_append(output_string, sep);
                output_string = g_string_append(output_string, text_from_time(di->fd->date));
                output_string = g_string_append(output_string, sep);
index ed39bb7..921d2b7 100644 (file)
@@ -777,7 +777,7 @@ static gchar *exif_build_formatted_localtime(ExifData *exif)
                {
                time_zone_image = g_strconcat("TZ=", timezone, NULL);
                time_zone_org = g_strconcat("TZ=", getenv("TZ"), NULL);
-               putenv("TZ=UTC");
+               setenv("TZ", "UTC", TRUE);
 
                memset(&tm_utc, 0, sizeof(tm_utc));
                if (exif_date_time && strptime(exif_date_time, "%Y:%m:%d:%H:%M:%S", &tm_utc))
index 793089c..b5df7c4 100644 (file)
@@ -1156,40 +1156,40 @@ void image_loader_delay_area_ready(ImageLoader *il, gboolean enable)
 /**************************************************************************************/
 /* execution via idle calls */
 
-static gboolean image_loader_idle_cb(gpointer data)
-{
-       gboolean ret = FALSE;
-       ImageLoader *il = static_cast<ImageLoader *>(data);
+//static gboolean image_loader_idle_cb(gpointer data)
+//{
+       //gboolean ret = FALSE;
+       //ImageLoader *il = static_cast<ImageLoader *>(data);
 
-       if (il->idle_id)
-               {
-               ret = image_loader_continue(il);
-               }
+       //if (il->idle_id)
+               //{
+               //ret = image_loader_continue(il);
+               //}
 
-       if (!ret)
-               {
-               image_loader_stop_source(il);
-               }
+       //if (!ret)
+               //{
+               //image_loader_stop_source(il);
+               //}
 
-       return ret;
-}
+       //return ret;
+//}
 
 
-static gboolean image_loader_start_idle(ImageLoader *il)
-{
-       gboolean ret;
+//static gboolean image_loader_start_idle(ImageLoader *il)
+//{
+       //gboolean ret;
 
-       if (!il) return FALSE;
+       //if (!il) return FALSE;
 
-       if (!il->fd) return FALSE;
+       //if (!il->fd) return FALSE;
 
-       if (!image_loader_setup_source(il)) return FALSE;
+       //if (!image_loader_setup_source(il)) return FALSE;
 
-       ret = image_loader_begin(il);
+       //ret = image_loader_begin(il);
 
-       if (ret && !il->done) il->idle_id = g_idle_add_full(il->idle_priority, image_loader_idle_cb, il, NULL);
-       return ret;
-}
+       //if (ret && !il->done) il->idle_id = g_idle_add_full(il->idle_priority, image_loader_idle_cb, il, NULL);
+       //return ret;
+//}
 
 /**************************************************************************************/
 /* execution via thread */
index 3994045..369a82f 100644 (file)
@@ -61,7 +61,7 @@ static LayoutStyle layout_config_styles[] = {
 
 static gint layout_config_style_count = sizeof(layout_config_styles) / sizeof(LayoutStyle);
 
-static gchar *layout_titles[] = { N_("Tools"), N_("Files"), N_("Image") };
+static const gchar *layout_titles[] = { N_("Tools"), N_("Files"), N_("Image") };
 
 
 static void layout_config_destroy(GtkWidget *UNUSED(widget), gpointer data)
index 268e2c2..0d8e0f1 100644 (file)
@@ -372,8 +372,9 @@ static void search_entry_icon_cb(GtkEntry *UNUSED(entry), GtkEntryIconPosition p
 
 static void filter_entry_icon_cb(GtkEntry *entry, GtkEntryIconPosition UNUSED(pos), GdkEvent *UNUSED(event), gpointer UNUSED(userdata))
 {
-       gtk_entry_set_text(entry, "");
-       set_regexp("");
+       const gchar *blank = "";
+       gtk_entry_set_text(entry, blank);
+       set_regexp(blank);
 }
 
 static LogWindow *log_window_create(LayoutWindow *lw)
index a41525d..7f41329 100644 (file)
@@ -83,6 +83,7 @@ void sig_handler_cb(int signo, siginfo_t *info, void *UNUSED(context))
        gint i = 0;
        guint64 addr;
        guint64 char_index;
+       ssize_t len;
 #ifdef HAVE_EXECINFO_H
        gint bt_size;
        void *bt[1024];
@@ -137,25 +138,25 @@ void sig_handler_cb(int signo, siginfo_t *info, void *UNUSED(context))
                i++;
                }
 
-       write(STDERR_FILENO, "Geeqie fatal error\n", 19);
-       write(STDERR_FILENO, "Signal: ", 8);
-       write(STDERR_FILENO, signal_name, strlen(signal_name));
-       write(STDERR_FILENO, "\n", 1);
+       len = write(STDERR_FILENO, "Geeqie fatal error\n", 19);
+       len = write(STDERR_FILENO, "Signal: ", 8);
+       len = write(STDERR_FILENO, signal_name, strlen(signal_name));
+       len = write(STDERR_FILENO, "\n", 1);
 
-       write(STDERR_FILENO, "Code: ", 6);
-       write(STDERR_FILENO,  (info->si_code == SEGV_MAPERR) ? "Address not mapped" : "Invalid permissions", strlen((info->si_code == SEGV_MAPERR) ? "Address not mapped" : "Invalid permissions"));
-       write(STDERR_FILENO, "\n", 1);
+       len = write(STDERR_FILENO, "Code: ", 6);
+       len = write(STDERR_FILENO,  (info->si_code == SEGV_MAPERR) ? "Address not mapped" : "Invalid permissions", strlen((info->si_code == SEGV_MAPERR) ? "Address not mapped" : "Invalid permissions"));
+       len = write(STDERR_FILENO, "\n", 1);
 
-       write(STDERR_FILENO, "Address: ", 9);
+       len = write(STDERR_FILENO, "Address: ", 9);
 
        if (info->si_addr == 0)
                {
-               write(STDERR_FILENO, "0x0\n", 4);
+               len = write(STDERR_FILENO, "0x0\n", 4);
                }
        else
                {
                /* Assume the address is 64-bit */
-               write(STDERR_FILENO, "0x", 2);
+               len = write(STDERR_FILENO, "0x", 2);
                addr = reinterpret_cast<guint64>(info->si_addr);
 
                for (i = 0; i < 16; i++)
@@ -164,9 +165,9 @@ void sig_handler_cb(int signo, siginfo_t *info, void *UNUSED(context))
                        char_index = char_index >> 60;
                        addr = addr << 4;
 
-                       write(STDERR_FILENO, &hex_char[char_index], 1);
+                       len = write(STDERR_FILENO, &hex_char[char_index], 1);
                        }
-               write(STDERR_FILENO, "\n", 1);
+               len = write(STDERR_FILENO, "\n", 1);
                }
 
 #ifdef HAVE_EXECINFO_H
@@ -1161,17 +1162,17 @@ static void sigbus_handler_cb(int UNUSED(signum), siginfo_t *info, void *UNUSED(
 }
 #endif
 
-static void setup_sigbus_handler(void)
-{
-#if defined(SIGBUS) && defined(SA_SIGINFO)
-       struct sigaction sigbus_action;
-       sigfillset(&sigbus_action.sa_mask);
-       sigbus_action.sa_sigaction = sigbus_handler_cb;
-       sigbus_action.sa_flags = SA_SIGINFO;
+//static void setup_sigbus_handler(void)
+//{
+//#if defined(SIGBUS) && defined(SA_SIGINFO)
+       //struct sigaction sigbus_action;
+       //sigfillset(&sigbus_action.sa_mask);
+       //sigbus_action.sa_sigaction = sigbus_handler_cb;
+       //sigbus_action.sa_flags = SA_SIGINFO;
 
-       sigaction(SIGBUS, &sigbus_action, NULL);
-#endif
-}
+       //sigaction(SIGBUS, &sigbus_action, NULL);
+//#endif
+//}
 
 static void setup_sig_handler(void)
 {
@@ -1270,8 +1271,6 @@ gint main(gint argc, gchar *argv[])
        gboolean single_dir = TRUE;
        LayoutWindow *lw;
        GtkSettings *default_settings;
-       gint fd_stderr[2];
-       GIOChannel *stderr_channel;
 
        gdk_set_allowed_backends("x11,*");
 
index e66019a..06a35d3 100644 (file)
@@ -167,7 +167,7 @@ gchar *sort_type_get_text(SortType method)
                        break;
                }
 
-       return "";
+       return _("");
 }
 
 static GtkWidget *submenu_add_sort_item(GtkWidget *menu,
@@ -267,7 +267,7 @@ gchar *zoom_type_get_text(ZoomMode method)
                        break;
                }
 
-       return "";
+       return _("");
 }
 
 static GtkWidget *submenu_add_zoom_item(GtkWidget *menu,
@@ -355,7 +355,7 @@ gchar *alter_type_get_text(AlterType type)
                        break;
                }
 
-       return "";
+       return _("");
 }
 
 static void submenu_add_alter_item(GtkWidget *menu, GCallback func, AlterType type,
index 53fb0c5..b142de2 100644 (file)
@@ -863,7 +863,7 @@ gboolean metadata_write_GPS_coord(FileData *fd, const gchar *key, gdouble value)
        gdouble min;
        gdouble param;
        char *coordinate;
-       char *ref;
+       const char *ref;
        gboolean ok = TRUE;
        char *old_locale, *saved_locale;
 
index 1f87038..e292fd0 100644 (file)
@@ -92,7 +92,7 @@ gchar *pan_date_value_string(time_t d, PanDateLengthType length)
 {
        struct tm td;
        gchar buf[128];
-       gchar *format = NULL;
+       const gchar *format = NULL;
 
        if (!localtime_r(&d, &td)) return g_strdup("");
 
index 76c5969..9e4ac9c 100644 (file)
@@ -106,7 +106,7 @@ static gchar *color_to_string(GdkColor *color)
        return g_strdup_printf("#%04X%04X%04X", color->red, color->green, color->blue);
 }
 
-void write_color_option(GString *str, gint indent, gchar *label, GdkColor *color)
+void write_color_option(GString *str, gint indent, const gchar *label, GdkColor *color)
 {
        if (color)
                {
index 729f366..6aa8f60 100644 (file)
@@ -27,7 +27,7 @@ void write_indent(GString *str, gint indent);
 void write_char_option(GString *str, gint indent, const gchar *label, const gchar *text);
 gboolean read_dummy_option(const gchar *option, const gchar *label, const gchar *message);
 gboolean read_char_option(const gchar *option, const gchar *label, const gchar *value, gchar **text);
-void write_color_option(GString *str, gint indent, gchar *label, GdkColor *color);
+void write_color_option(GString *str, gint indent, const gchar *label, GdkColor *color);
 gboolean read_color_option(const gchar *option, const gchar *label, const gchar *value, GdkColor *color);
 void write_int_option(GString *str, gint indent, const gchar *label, gint n);
 gboolean read_int_option(const gchar *option, const gchar *label, const gchar *value, gint *n);
index be20952..55f23ee 100644 (file)
@@ -52,7 +52,7 @@ struct _BookMarkData
 {
        GtkWidget *widget;
        GtkWidget *box;
-       gchar *key;
+       const gchar *key;
 
        void (*select_func)(const gchar *path, gpointer data);
        gpointer select_data;
@@ -94,8 +94,8 @@ enum {
 
 static GtkTargetEntry bookmark_drop_types[] = {
        { const_cast<gchar *>("text/uri-list"), 0, TARGET_URI_LIST },
-       { "x-url/http",    0, TARGET_X_URL },
-       { "_NETSCAPE_URL", 0, TARGET_X_URL }
+       { const_cast<gchar *>("x-url/http"),    0, TARGET_X_URL },
+       { const_cast<gchar *>("_NETSCAPE_URL"), 0, TARGET_X_URL }
 };
 #define bookmark_drop_types_n 3
 
@@ -191,10 +191,10 @@ static gchar *bookmark_string(const gchar *name, const gchar *path, const gchar
 
        if (icon)
                {
-               return g_strdup_printf("%s"MARKER_PATH"%s"MARKER_ICON"%s", name, path, icon);
+               return g_strdup_printf("%s" MARKER_PATH "%s" MARKER_ICON "%s", name, path, icon);
                }
 
-       return g_strdup_printf("%s"MARKER_PATH"%s", name, path);
+       return g_strdup_printf("%s" MARKER_PATH "%s", name, path);
 }
 
 static void bookmark_select_cb(GtkWidget *button, gpointer data)
@@ -318,7 +318,7 @@ static void bookmark_move(BookMarkData *bm, GtkWidget *button, gint direction)
        BookButtonData *b;
        gint p;
        GList *list;
-       gchar *key_holder;
+       const gchar *key_holder;
 
        if (!bm->editable) return;
 
@@ -742,7 +742,7 @@ static void bookmark_list_destroy(GtkWidget *UNUSED(widget), gpointer data)
 
        bookmark_widget_list = g_list_remove(bookmark_widget_list, bm);
 
-       g_free(bm->key);
+       g_free((gpointer)bm->key);
        g_free(bm);
 }
 
@@ -811,7 +811,7 @@ void bookmark_list_set_key(GtkWidget *list, const gchar *key)
 
        if (bm->key && strcmp(bm->key, key) == 0) return;
 
-       g_free(bm->key);
+       g_free((gpointer)bm->key);
        bm->key = g_strdup(key);
 
        bookmark_populate(bm);
index ed169d6..f0bff26 100644 (file)
@@ -374,12 +374,12 @@ void pref_checkbox_link_sensitivity(GtkWidget *button, GtkWidget *widget)
        pref_checkbox_link_sensitivity_cb(button, widget);
 }
 
-static void pref_checkbox_link_sensitivity_swap_cb(GtkWidget *button, gpointer data)
-{
-       GtkWidget *widget = static_cast<GtkWidget *>(data);
+//static void pref_checkbox_link_sensitivity_swap_cb(GtkWidget *button, gpointer data)
+//{
+       //GtkWidget *widget = static_cast<GtkWidget *>(data);
 
-       gtk_widget_set_sensitive(widget, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
-}
+       //gtk_widget_set_sensitive(widget, !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)));
+//}
 
 //void pref_checkbox_link_sensitivity_swap(GtkWidget *button, GtkWidget *widget)
 //{
@@ -439,15 +439,15 @@ GtkWidget *pref_radiobutton_new(GtkWidget *parent_box, GtkWidget *sibling,
 
 #define PREF_RADIO_VALUE_KEY "pref_radio_value"
 
-static void pref_radiobutton_int_cb(GtkWidget *widget, gpointer data)
-{
-       gboolean *result = static_cast<gboolean *>(data);
+//static void pref_radiobutton_int_cb(GtkWidget *widget, gpointer data)
+//{
+       //gboolean *result = static_cast<gboolean *>(data);
 
-       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
-               {
-               *result = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), PREF_RADIO_VALUE_KEY));
-               }
-}
+       //if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
+               //{
+               //*result = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), PREF_RADIO_VALUE_KEY));
+               //}
+//}
 
 //GtkWidget *pref_radiobutton_new_int(GtkWidget *parent_box, GtkWidget *sibling,
                                    //const gchar *text, gboolean active,
index 6951f7a..d9961e6 100644 (file)
@@ -845,7 +845,7 @@ static void tab_completion_select_show(TabCompData *td)
 {
        const gchar *title;
        const gchar *path;
-       gchar *filter = NULL;
+       const gchar *filter = NULL;
        gchar *filter_desc = NULL;
 
        if (td->fd)
index 04434ff..446a081 100644 (file)
@@ -368,7 +368,7 @@ static void vf_pop_menu_open_archive_cb(GtkWidget *UNUSED(widget), gpointer data
 {
        ViewFile *vf = (ViewFile *)data;
        LayoutWindow *lw_new;
-       FileData *fd;
+       FileData *fd = NULL;
        gchar *dest_dir;
 
        switch (vf->type)