logo

badwolf

minimalist and privacy-oriented web browser based on WebKitGTK git clone https://hacktivis.me/git/badwolf.git
commit: 9d7d1970c95801f0ef09c9dbff6b510d69ee7b6e
parent 47f4e147e0f859acda4e829cd39c0994ebe999d5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 24 Aug 2022 16:37:38 +0200

Replace casts to (void) to UNUSED macro

Improves readability and as the parameter name is mangled,
we can be sure of it being actually unused

Diffstat:

Mbadwolf.c111+++++++++++++++++++++++++++++--------------------------------------------------
Mbadwolf.h8++++++++
Mbookmarks.c3+--
Mdownloads.c11+++++------
Mkeybindings.c15+++++----------
5 files changed, 60 insertions(+), 88 deletions(-)

diff --git a/badwolf.c b/badwolf.c @@ -75,9 +75,8 @@ notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, void content_managerCb_ready(GObject *store, GAsyncResult *result, gpointer user_data); static gboolean -WebViewCb_close(WebKitWebView *webView, gpointer user_data) +WebViewCb_close(WebKitWebView *UNUSED(webView), gpointer user_data) { - (void)webView; struct Client *browser = (struct Client *)user_data; gtk_widget_destroy(browser->box); @@ -88,11 +87,10 @@ WebViewCb_close(WebKitWebView *webView, gpointer user_data) } static gboolean -WebViewCb_web_process_terminated(WebKitWebView *webView, +WebViewCb_web_process_terminated(WebKitWebView *UNUSED(webView), WebKitWebProcessTerminationReason reason, gpointer user_data) { - (void)webView; struct Client *browser = (struct Client *)user_data; switch(reason) @@ -114,10 +112,8 @@ WebViewCb_web_process_terminated(WebKitWebView *webView, } static gboolean -WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data) +WebViewCb_notify__uri(WebKitWebView *UNUSED(webView), GParamSpec *UNUSED(pspec), gpointer user_data) { - (void)webView; - (void)pspec; const gchar *location_uri; struct Client *browser = (struct Client *)user_data; @@ -136,7 +132,6 @@ WebViewCb_notify__uri(WebKitWebView *webView, GParamSpec *pspec, gpointer user_d GtkWidget * badwolf_new_tab_box(const gchar *title, struct Client *browser) { - (void)browser; /* flawfinder: ignore. bound checks are done */ char context_id_str[BADWOLF_CTX_SIZ] = {0, 0, 0, 0, 0, 0, 0}; @@ -195,10 +190,10 @@ badwolf_new_tab_box(const gchar *title, struct Client *browser) } static gboolean -WebViewCb_notify__title(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data) +WebViewCb_notify__title(WebKitWebView *UNUSED(webView), + GParamSpec *UNUSED(pspec), + gpointer user_data) { - (void)webView; - (void)pspec; struct Client *browser = (struct Client *)user_data; webView_tab_label_change(browser, NULL); @@ -207,10 +202,10 @@ WebViewCb_notify__title(WebKitWebView *webView, GParamSpec *pspec, gpointer user } static gboolean -WebViewCb_notify__is__playing__audio(WebKitWebView *webView, GParamSpec *pspec, gpointer user_data) +WebViewCb_notify__is__playing__audio(WebKitWebView *UNUSED(webView), + GParamSpec *UNUSED(pspec), + gpointer user_data) { - (void)webView; - (void)pspec; struct Client *browser = (struct Client *)user_data; webView_tab_label_change(browser, NULL); @@ -240,12 +235,10 @@ webView_tab_label_change(struct Client *browser, const gchar *title) } static gboolean -WebViewCb_notify__estimated_load_progress(WebKitWebView *webView, - GParamSpec *pspec, +WebViewCb_notify__estimated_load_progress(WebKitWebView *UNUSED(webView), + GParamSpec *UNUSED(pspec), gpointer user_data) { - (void)webView; - (void)pspec; struct Client *browser = (struct Client *)user_data; gdouble progress; @@ -259,13 +252,11 @@ WebViewCb_notify__estimated_load_progress(WebKitWebView *webView, } static gboolean -WebViewCb_mouse_target_changed(WebKitWebView *webView, +WebViewCb_mouse_target_changed(WebKitWebView *UNUSED(webView), WebKitHitTestResult *hit, - guint modifiers, + guint UNUSED(modifiers), gpointer user_data) { - (void)webView; - (void)modifiers; struct Client *browser = (struct Client *)user_data; if(webkit_hit_test_result_context_is_link(hit)) @@ -281,9 +272,8 @@ WebViewCb_mouse_target_changed(WebKitWebView *webView, } static gboolean -WebViewCb_scroll_event(GtkWidget *widget, GdkEvent *event, gpointer data) +WebViewCb_scroll_event(GtkWidget *UNUSED(widget), GdkEvent *event, gpointer data) { - (void)widget; struct Client *browser = (struct Client *)data; gdouble delta_x, delta_y; gdouble zoom; @@ -302,10 +292,9 @@ WebViewCb_scroll_event(GtkWidget *widget, GdkEvent *event, gpointer data) static WebKitWebView * WebViewCb_create(WebKitWebView *related_web_view, - WebKitNavigationAction *navigation_action, + WebKitNavigationAction *UNUSED(navigation_action), gpointer user_data) { - (void)navigation_action; struct Client *old_browser = (struct Client *)user_data; struct Client *browser = NULL; @@ -321,27 +310,22 @@ WebViewCb_create(WebKitWebView *related_web_view, } static gboolean -WebViewCb_permission_request(WebKitWebView *web_view, +WebViewCb_permission_request(WebKitWebView *UNUSED(web_view), WebKitPermissionRequest *request, - gpointer user_data) + gpointer UNUSED(user_data)) { - (void)web_view; - (void)user_data; - webkit_permission_request_deny(request); return TRUE; /* Stop other handlers */ } static gboolean -WebViewCb_decide_policy(WebKitWebView *web_view, +WebViewCb_decide_policy(WebKitWebView *UNUSED(web_view), WebKitPolicyDecision *decision, WebKitPolicyDecisionType decision_type, - gpointer user_data) + gpointer UNUSED(user_data)) { WebKitResponsePolicyDecision *r; - (void)web_view; - (void)user_data; switch(decision_type) { @@ -361,10 +345,10 @@ WebViewCb_decide_policy(WebKitWebView *web_view, } static void -WebViewCb_load_changed(WebKitWebView *webView, WebKitLoadEvent load_event, gpointer user_data) +WebViewCb_load_changed(WebKitWebView *UNUSED(webView), + WebKitLoadEvent UNUSED(load_event), + gpointer user_data) { - (void)webView; - (void)load_event; struct Client *browser = (struct Client *)user_data; gtk_widget_set_sensitive(browser->back, webkit_web_view_can_go_back(browser->webView)); @@ -406,15 +390,12 @@ detail_tls_certificate_flags(GTlsCertificateFlags tls_errors) } static gboolean -WebViewCb_load_failed_with_tls_errors(WebKitWebView *web_view, +WebViewCb_load_failed_with_tls_errors(WebKitWebView *UNUSED(web_view), gchar *failing_text, GTlsCertificate *certificate, GTlsCertificateFlags errors, gpointer user_data) { - (void)web_view; - (void)certificate; - (void)errors; struct Client *browser = (struct Client *)user_data; gchar *error_details = detail_tls_certificate_flags(errors); gint dialog_response; @@ -475,11 +456,10 @@ WebViewCb_load_failed_with_tls_errors(WebKitWebView *web_view, } static void -web_contextCb_download_started(WebKitWebContext *web_context, +web_contextCb_download_started(WebKitWebContext *UNUSED(web_context), WebKitDownload *webkit_download, gpointer user_data) { - (void)web_context; struct Client *browser = (struct Client *)user_data; struct Download *download = malloc(sizeof(struct Download)); @@ -550,27 +530,24 @@ auto_load_imagesCb_toggled(GtkButton *auto_load_images, gpointer user_data) } static void -backCb_clicked(GtkButton *back, gpointer user_data) +backCb_clicked(GtkButton *UNUSED(back), gpointer user_data) { - (void)back; struct Client *browser = (struct Client *)user_data; webkit_web_view_go_back(browser->webView); } static void -forwardCb_clicked(GtkButton *forward, gpointer user_data) +forwardCb_clicked(GtkButton *UNUSED(forward), gpointer user_data) { - (void)forward; struct Client *browser = (struct Client *)user_data; webkit_web_view_go_forward(browser->webView); } static void -printCb_clicked(GtkButton *print, gpointer user_data) +printCb_clicked(GtkButton *UNUSED(print), gpointer user_data) { - (void)print; struct Client *browser = (struct Client *)user_data; WebKitPrintOperation *print_operation = webkit_print_operation_new(browser->webView); @@ -579,9 +556,8 @@ printCb_clicked(GtkButton *print, gpointer user_data) } static gboolean -SearchEntryCb_next__match(GtkSearchEntry *search, gpointer user_data) +SearchEntryCb_next__match(GtkSearchEntry *UNUSED(search), gpointer user_data) { - (void)search; struct Client *browser = (struct Client *)user_data; WebKitFindController *findController = webkit_web_view_get_find_controller(browser->webView); @@ -591,9 +567,8 @@ SearchEntryCb_next__match(GtkSearchEntry *search, gpointer user_data) } static gboolean -SearchEntryCb_previous__match(GtkSearchEntry *search, gpointer user_data) +SearchEntryCb_previous__match(GtkSearchEntry *UNUSED(search), gpointer user_data) { - (void)search; struct Client *browser = (struct Client *)user_data; WebKitFindController *findController = webkit_web_view_get_find_controller(browser->webView); @@ -615,9 +590,8 @@ SearchEntryCb_search__changed(GtkSearchEntry *search, gpointer user_data) } static gboolean -SearchEntryCb_stop__search(GtkSearchEntry *search, gpointer user_data) +SearchEntryCb_stop__search(GtkSearchEntry *UNUSED(search), gpointer user_data) { - (void)search; struct Client *browser = (struct Client *)user_data; WebKitFindController *findController = webkit_web_view_get_find_controller(browser->webView); @@ -627,11 +601,8 @@ SearchEntryCb_stop__search(GtkSearchEntry *search, gpointer user_data) } static gboolean -widgetCb_drop_button3_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) +widgetCb_drop_button3_event(GtkWidget *UNUSED(widget), GdkEvent *event, gpointer UNUSED(user_data)) { - (void)widget; - (void)user_data; - // Button3 being right-click on right-handed mode, left-click on left-handed mode return ((GdkEventButton *)event)->button == 3; } @@ -944,9 +915,8 @@ badwolf_new_tab(GtkNotebook *notebook, struct Client *browser, bool auto_switch) } static void -new_tabCb_clicked(GtkButton *new_tab, gpointer user_data) +new_tabCb_clicked(GtkButton *UNUSED(new_tab), gpointer user_data) { - (void)new_tab; struct Window *window = (struct Window *)user_data; struct Client *browser = new_browser(window, NULL, NULL); @@ -954,18 +924,19 @@ new_tabCb_clicked(GtkButton *new_tab, gpointer user_data) } static void -closeCb_clicked(GtkButton *close, gpointer user_data) +closeCb_clicked(GtkButton *UNUSED(close), gpointer user_data) { - (void)close; struct Client *browser = (struct Client *)user_data; webkit_web_view_try_close(browser->webView); } static void -notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data) +notebookCb_switch__page(GtkNotebook *notebook, + GtkWidget *page, + guint UNUSED(page_num), + gpointer user_data) { - (void)page_num; struct Window *window = (struct Window *)user_data; GtkWidget *label = gtk_notebook_get_tab_label(notebook, page); @@ -974,9 +945,8 @@ notebookCb_switch__page(GtkNotebook *notebook, GtkWidget *page, guint page_num, } void -content_managerCb_ready(GObject *store, GAsyncResult *result, gpointer user_data) +content_managerCb_ready(GObject *UNUSED(store), GAsyncResult *result, gpointer user_data) { - (void)store; struct Window *window = (struct Window *)user_data; GError *err = NULL; @@ -1005,9 +975,10 @@ content_managerCb_ready(GObject *store, GAsyncResult *result, gpointer user_data } static void -storeCb_finish(WebKitUserContentFilterStore *store, GAsyncResult *result, gpointer user_data) +storeCb_finish(WebKitUserContentFilterStore *UNUSED(store), + GAsyncResult *result, + gpointer user_data) { - (void)store; struct Window *window = (struct Window *)user_data; GError *err = NULL; diff --git a/badwolf.h b/badwolf.h @@ -12,6 +12,14 @@ #error WebkitGTK 2.32.0 is the latest supported version for badwolf. #endif +#ifdef UNUSED +#error UNUSED is already defined +#elif defined(__GNUC__) +#define UNUSED(x) UNUSED_##x __attribute__((unused)) +#else +#define UNUSED(x) x +#endif + extern const gchar *homepage; extern const gchar *version; diff --git a/bookmarks.c b/bookmarks.c @@ -17,9 +17,8 @@ static gboolean location_completion_matches(GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, - gpointer user_data) + gpointer UNUSED(user_data)) { - (void)user_data; gchar *buffer; gchar *pattern; gboolean result; diff --git a/downloads.c b/downloads.c @@ -10,9 +10,8 @@ #include <glib/gi18n.h> /* _() and other internationalization/localization helpers */ static void -download_stop_iconCb_clicked(GtkButton *stop_icon, gpointer user_data) +download_stop_iconCb_clicked(GtkButton *UNUSED(stop_icon), gpointer user_data) { - (void)stop_icon; WebKitDownload *webkit_download = (WebKitDownload *)user_data; webkit_download_cancel(webkit_download); @@ -63,11 +62,10 @@ download_new_entry(WebKitDownload *webkit_download, struct Download *download) } void -downloadCb_created_destination(WebKitDownload *webkit_download, +downloadCb_created_destination(WebKitDownload *UNUSED(webkit_download), gchar *destination, gpointer user_data) { - (void)webkit_download; char *markup; struct Download *download = (struct Download *)user_data; @@ -159,9 +157,10 @@ downloadCb_finished(WebKitDownload *webkit_download, gpointer user_data) } void -downloadCb_received_data(WebKitDownload *webkit_download, guint64 data_lenght, gpointer user_data) +downloadCb_received_data(WebKitDownload *webkit_download, + guint64 UNUSED(data_lenght), + gpointer user_data) { - (void)data_lenght; struct Download *download = (struct Download *)user_data; /* flawfinder: ignore. proper buffer limits are used */ char formatted[BUFSIZ]; diff --git a/keybindings.c b/keybindings.c @@ -11,7 +11,6 @@ static gboolean about_dialogCb_activate_link(GtkAboutDialog *about_dialog, gchar *uri, gpointer user_data) { - (void)about_dialog; struct Window *window = (struct Window *)user_data; badwolf_new_tab(GTK_NOTEBOOK(window->notebook), new_browser(window, uri, NULL), TRUE); @@ -50,7 +49,7 @@ badwolf_about_dialog(GtkWindow *main_window, gpointer user_data) g_signal_connect(about_dialog, "activate-link", G_CALLBACK(about_dialogCb_activate_link), window); - (void)gtk_dialog_run(GTK_DIALOG(about_dialog)); + gtk_dialog_run(GTK_DIALOG(about_dialog)); gtk_widget_destroy(about_dialog); } @@ -159,9 +158,8 @@ commonCb_key_press_event(struct Window *window, GdkEvent *event, struct Client * } gboolean -WebViewCb_key_press_event(WebKitWebView *webView, GdkEvent *event, gpointer user_data) +WebViewCb_key_press_event(WebKitWebView *UNUSED(webView), GdkEvent *event, gpointer user_data) { - (void)webView; struct Client *browser = (struct Client *)user_data; if(commonCb_key_press_event(browser->window, event, browser)) return TRUE; @@ -170,9 +168,8 @@ WebViewCb_key_press_event(WebKitWebView *webView, GdkEvent *event, gpointer user } gboolean -boxCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) +boxCb_key_press_event(GtkWidget *UNUSED(widget), GdkEvent *event, gpointer user_data) { - (void)widget; struct Client *browser = (struct Client *)user_data; if(commonCb_key_press_event(browser->window, event, browser)) return TRUE; @@ -181,9 +178,8 @@ boxCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) } gboolean -main_windowCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) +main_windowCb_key_press_event(GtkWidget *UNUSED(widget), GdkEvent *event, gpointer user_data) { - (void)widget; struct Window *window = (struct Window *)user_data; if(commonCb_key_press_event(window, event, NULL)) return TRUE; @@ -192,9 +188,8 @@ main_windowCb_key_press_event(GtkWidget *widget, GdkEvent *event, gpointer user_ } gboolean -tab_boxCb_button_release_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) +tab_boxCb_button_release_event(GtkWidget *UNUSED(widget), GdkEvent *event, gpointer user_data) { - (void)widget; struct Client *browser = (struct Client *)user_data; if(((GdkEventButton *)event)->button == GDK_BUTTON_MIDDLE)