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

19 files changed:
.clang-tidy
src/bar-gps.cc
src/bar-sort.cc
src/cache-maint.cc
src/collect-dlg.cc
src/dupe.cc
src/editors.cc
src/image-load-webp.cc
src/image.cc
src/layout-image.cc
src/layout-util.cc
src/main.cc
src/pixbuf-renderer.cc
src/pixbuf-util.cc
src/ui-fileops.cc
src/ui-misc.cc
src/ui-pathsel.cc
src/utilops.cc
src/view-dir.cc

index 7ec167b..cbe7bd1 100644 (file)
@@ -49,7 +49,6 @@ Checks: >
   -modernize-raw-string-literal,
   -modernize-redundant-void-arg,
   -modernize-use-auto,
-  -modernize-use-nullptr,
   -modernize-use-trailing-return-type,
   -modernize-use-using,
   -performance-no-int-to-ptr,
index f1ca821..a0d2951 100644 (file)
@@ -845,7 +845,7 @@ static void bar_pane_gps_map_centreing(PaneGPSData *pgd)
                                "map_centering", nullptr, TRUE, nullptr, pgd);
        generic_dialog_add_message(gd, GQ_ICON_DIALOG_INFO,
                                "Map Centering", message->str, TRUE);
-       generic_dialog_add_button(gd, GQ_ICON_OK, "OK", NULL, TRUE);
+       generic_dialog_add_button(gd, GQ_ICON_OK, "OK", nullptr, TRUE);
 
        gtk_widget_show(gd->dialog);
 
index 22a4149..11c8f00 100644 (file)
@@ -435,7 +435,7 @@ static void bar_filter_help_dialog()
        generic_dialog_add_message(gd, GQ_ICON_DIALOG_INFO,
                                "Sort Manager Operations", _("Additional operations utilising plugins\nmay be included by setting:\n\nX-Geeqie-Filter=true\n\nin the plugin file."), TRUE);
        generic_dialog_add_button(gd, GQ_ICON_HELP, _("Help"), bar_filter_help_cb, TRUE);
-       generic_dialog_add_button(gd, GQ_ICON_OK, "OK", NULL, TRUE);
+       generic_dialog_add_button(gd, GQ_ICON_OK, "OK", nullptr, TRUE);
 
        gtk_widget_show(gd->dialog);
 }
index 8440804..f73236d 100644 (file)
@@ -1167,7 +1167,7 @@ static void cache_manager_standard_process(GtkWidget *widget, gboolean clear)
                                                    cache_manager_standard_clean_stop_cb, FALSE);
        gtk_widget_set_sensitive(cd->button_stop, FALSE);
 
-       generic_dialog_add_message(cd->gd, icon_name, msg, NULL, FALSE);
+       generic_dialog_add_message(cd->gd, icon_name, msg, nullptr, FALSE);
 
        cd->progress = gtk_progress_bar_new();
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(cd->progress), _("click start to begin"));
index dca4aa5..8e0bc6f 100644 (file)
@@ -142,7 +142,7 @@ static void collection_save_or_append_dialog(gint type, CollectionData *cd)
 
                title = _("Save collection");
 
-               gdlg = file_util_gen_dlg(title, "dlg_collection_save", NULL, FALSE, collection_save_or_load_dialog_close_cb, cd);
+               gdlg = file_util_gen_dlg(title, "dlg_collection_save", nullptr, FALSE, collection_save_or_load_dialog_close_cb, cd);
 
                generic_dialog_add_message(GENERIC_DIALOG(gdlg), nullptr, title, _("Existing collections:"), FALSE);
                generic_dialog_add_button(gdlg, GQ_ICON_SAVE, _("Save"), collection_save_cb, TRUE);
index a4bdc67..7da7d98 100644 (file)
@@ -481,7 +481,7 @@ static DupeItem *dupe_item_find_fd_by_list_unused(FileData *fd, GList *work)
                work = work->next;
                }
 
-       return NULL;
+       return nullptr;
 }
 
 static DupeItem *dupe_item_find_fd_unused(DupeWindow *dw, FileData *fd)
@@ -505,7 +505,7 @@ static DupeItem *dupe_item_find_path_by_list_unused(const gchar *path, GList *wo
                work = work->next;
                }
 
-       return NULL;
+       return nullptr;
 }
 
 static DupeItem *dupe_item_find_path_unused(DupeWindow *dw, const gchar *path)
index f3a2a53..3d47382 100644 (file)
@@ -1441,7 +1441,7 @@ const gchar *editor_get_name_unused(const gchar *key)
 {
        EditorDescription *editor = static_cast<EditorDescription *>(g_hash_table_lookup(editors, key));
 
-       if (!editor) return NULL;
+       if (!editor) return nullptr;
 
        return editor->name;
 }
index 9c1fa40..61403d4 100644 (file)
@@ -75,7 +75,7 @@ static gboolean image_loader_webp_load(gpointer loader, const guchar *buf, gsize
                data = WebPDecodeRGB(buf, count, &width, &height);
                }
 
-       ld->pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, features.has_alpha, 8, width, height, width * (features.has_alpha ? 4 : 3), free_buffer, NULL);
+       ld->pixbuf = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, features.has_alpha, 8, width, height, width * (features.has_alpha ? 4 : 3), free_buffer, nullptr);
 
        ld->area_updated_cb(loader, 0, 0, width, height, ld->data);
 
@@ -141,7 +141,7 @@ DEBUG_0("        "     );
        funcs->loader_new = image_loader_webp_new;
        funcs->set_size = image_loader_webp_set_size;
        funcs->load = image_loader_webp_load;
-       funcs->write = NULL;
+       funcs->write = nullptr;
        funcs->get_pixbuf = image_loader_webp_get_pixbuf;
        funcs->close = image_loader_webp_close;
        funcs->abort = image_loader_webp_abort;
index 2d11182..3bf37db 100644 (file)
@@ -198,7 +198,7 @@ static void image_release_cb(PixbufRenderer *, GdkEventButton *event, gpointer d
                layout_valid(&lw);
                }
 
-       defined_mouse_buttons(NULL, event, lw);
+       defined_mouse_buttons(nullptr, event, lw);
 }
 
 static void image_drag_cb(PixbufRenderer *pr, GdkEventMotion *event, gpointer data)
index 885f7a8..49fea7f 100644 (file)
@@ -1426,7 +1426,7 @@ const gchar *layout_image_get_path(LayoutWindow *lw)
 #pragma GCC diagnostic ignored "-Wunused-function"
 const gchar *layout_image_get_name_unused(LayoutWindow *lw)
 {
-       if (!layout_valid(&lw)) return NULL;
+       if (!layout_valid(&lw)) return nullptr;
 
        return image_get_name(lw->image);
 }
index 6b018fe..5dc2ff5 100644 (file)
@@ -913,7 +913,7 @@ struct OpenWithData
 
 void open_with_response_cb(GtkDialog *, gint response_id, gpointer data)
 {
-       GError *error = NULL;
+       GError *error = nullptr;
        auto open_with_data = static_cast<OpenWithData *>(data);
 
        if (response_id == GTK_RESPONSE_OK)
@@ -945,7 +945,7 @@ static void open_with_application_selected_cb(GtkAppChooserWidget *, GAppInfo *a
 
 static void open_with_application_activated_cb(GtkAppChooserWidget *, GAppInfo *application, gpointer data)
 {
-       GError *error = NULL;
+       GError *error = nullptr;
        auto open_with_data = static_cast<OpenWithData *>(data);
 
        g_app_info_launch(application, open_with_data->g_file_list, nullptr, &error);
index 69881d0..3a9c632 100644 (file)
@@ -1100,7 +1100,7 @@ static gint exit_confirm_dlg()
        g_free(msg);
        msg = g_strdup_printf(_("Quit %s"), GQ_APPNAME);
 
-       message = g_string_new(NULL);
+       message = g_string_new(nullptr);
 
        if (collection_window_modified_exists())
                {
@@ -1182,7 +1182,7 @@ static void setup_sigbus_handler_unused(void)
        sigbus_action.sa_sigaction = sigbus_handler_cb_unused;
        sigbus_action.sa_flags = SA_SIGINFO;
 
-       sigaction(SIGBUS, &sigbus_action, NULL);
+       sigaction(SIGBUS, &sigbus_action, nullptr);
 #endif
 }
 #pragma GCC diagnostic pop
index b6716e1..89bccd9 100644 (file)
@@ -2965,7 +2965,7 @@ gboolean pixbuf_renderer_get_visible_rect(PixbufRenderer *pr, GdkRectangle *rect
 gboolean pixbuf_renderer_get_virtual_rect_unused(PixbufRenderer *pr, GdkRectangle *rect)
 {
        g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), FALSE);
-       g_return_val_if_fail(rect != NULL, FALSE);
+       g_return_val_if_fail(rect != nullptr, FALSE);
 
        if ((!pr->pixbuf && !pr->source_tiles_enabled))
                {
index c5f16ae..c2780e2 100644 (file)
@@ -64,7 +64,7 @@ gboolean pixbuf_to_file_as_png(GdkPixbuf *pixbuf, const gchar *filename)
 #pragma GCC diagnostic ignored "-Wunused-function"
 gboolean pixbuf_to_file_as_jpg_unused(GdkPixbuf *pixbuf, const gchar *filename, gint quality)
 {
-       GError *error = NULL;
+       GError *error = nullptr;
        gchar *qbuf;
        gboolean ret;
 
index ca0e238..7e52832 100644 (file)
@@ -790,16 +790,16 @@ gchar *unique_filename_simple_unused(const gchar *path)
        const gchar *name;
        const gchar *ext;
 
-       if (!path) return NULL;
+       if (!path) return nullptr;
 
        name = filename_from_path(path);
-       if (!name) return NULL;
+       if (!name) return nullptr;
 
        ext = registered_extension_from_path(name);
 
        if (!ext)
                {
-               unique = unique_filename(path, NULL, "_", TRUE);
+               unique = unique_filename(path, nullptr, "_", TRUE);
                }
        else
                {
index 6c84f47..d814030 100644 (file)
@@ -1305,7 +1305,7 @@ gboolean pref_list_double_get_unused(const gchar *group, const gchar *key, gdoub
 
        if (pref_list_get(group, key, PREF_LIST_MARKER_DOUBLE, &text) && text)
                {
-               *result = g_ascii_strtod(text, NULL);
+               *result = g_ascii_strtod(text, nullptr);
                return TRUE;
                }
 
index 3f198e4..29a308b 100644 (file)
@@ -1210,7 +1210,7 @@ GtkWidget *path_selection_new_with_files(GtkWidget *entry, const gchar *path,
 #pragma GCC diagnostic ignored "-Wunused-function"
 GtkWidget *path_selection_new_unused(const gchar *path, GtkWidget *entry)
 {
-       return path_selection_new_with_files(entry, path, NULL, NULL);
+       return path_selection_new_with_files(entry, path, nullptr, nullptr);
 }
 
 void path_selection_sync_to_entry_unused(GtkWidget *entry)
index 76bcea9..63bfb0c 100644 (file)
@@ -3119,7 +3119,7 @@ void file_util_start_editor_from_filelist(const gchar *key, GList *list, const g
 #pragma GCC diagnostic ignored "-Wunused-function"
 void file_util_start_filter_from_file_unused(const gchar *key, FileData *fd, const gchar *dest_path, GtkWidget *parent)
 {
-       file_util_start_editor_full(key, fd, NULL, dest_path, NULL, parent, UTILITY_PHASE_ENTERING);
+       file_util_start_editor_full(key, fd, nullptr, dest_path, nullptr, parent, UTILITY_PHASE_ENTERING);
 }
 #pragma GCC diagnostic pop
 
index 793dab3..dbe89b5 100644 (file)
@@ -236,7 +236,7 @@ void vd_refresh(ViewDir *vd)
 #pragma GCC diagnostic ignored "-Wunused-function"
 const gchar *vd_row_get_path_unused(ViewDir *vd, gint row)
 {
-       const gchar *ret = NULL;
+       const gchar *ret = nullptr;
 
        switch (vd->type)
        {