From dac09b872821da22108636455b5a8941ba9e52d6 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 1 Dec 2021 13:14:36 +0100 Subject: [PATCH] Cleanups based on cppcheck. --- include/helper.h | 9 --------- include/theme.h | 5 ----- include/widgets/listview.h | 9 --------- include/widgets/widget.h | 12 ++---------- lexer/theme-lexer.l | 36 ++++++++++++++++-------------------- source/helper.c | 9 --------- source/theme.c | 16 +++------------- source/widgets/listview.c | 6 ------ source/widgets/widget.c | 11 ++--------- 9 files changed, 23 insertions(+), 90 deletions(-) diff --git a/include/helper.h b/include/helper.h index 6de3c74c..7ae37a65 100644 --- a/include/helper.h +++ b/include/helper.h @@ -228,15 +228,6 @@ char *rofi_force_utf8(const gchar *data, ssize_t length); */ char *rofi_latin_to_utf8_strdup(const char *input, gssize length); -/** - * @param text the string to escape - * - * Escape XML markup from the string. text is freed. - * - * @return the escaped string - */ -gchar *rofi_escape_markup(gchar *text); - /** * @param pattern The user input to match against. * @param plen Pattern length. diff --git a/include/theme.h b/include/theme.h index 729a8264..30b501f2 100644 --- a/include/theme.h +++ b/include/theme.h @@ -404,11 +404,6 @@ Property *rofi_theme_find_property(ThemeWidget *widget, PropertyType type, */ GList *rofi_theme_get_list(const widget *widget, const char *property, const char *defaults); -/** - * Checks if a theme is set, or is empty. - * @returns TRUE when empty. - */ -gboolean rofi_theme_is_empty(void); /** * Reset the current theme. diff --git a/include/widgets/listview.h b/include/widgets/listview.h index 9b551f2b..f7ebec66 100644 --- a/include/widgets/listview.h +++ b/include/widgets/listview.h @@ -214,15 +214,6 @@ void listview_set_multi_select(listview *lv, gboolean enable); */ void listview_set_num_lines(listview *lv, unsigned int num_lines); -/** - * @param lv Handler to the listview object. - * - * Get the maximum number of lines to display. - * - * @returns get the number of lines to display. - */ -unsigned int listview_get_num_lines(listview *lv); - /** * @param lv Handler to the listview object. * diff --git a/include/widgets/widget.h b/include/widgets/widget.h index aa64b84f..68706cfe 100644 --- a/include/widgets/widget.h +++ b/include/widgets/widget.h @@ -138,14 +138,6 @@ int widget_intersect(const widget *widget, int x, int y); */ void widget_move(widget *widget, short x, short y); -/** - * @param widget Handle to widget - * - * Get the type of the widget. - * @returns The type of the widget. - */ -WidgetType widget_type(widget *widget); - /** * @param widget Handle to widget * @param type The widget type. @@ -292,8 +284,8 @@ widget *widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y); * * @returns Whether the action would be handled or not */ -WidgetTriggerActionResult widget_check_action(widget *wid, guint action, - gint x, gint y); +WidgetTriggerActionResult widget_check_action(widget *wid, guint action, gint x, + gint y); /** * @param wid The widget handle diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index e9b8e99f..bf32ecb9 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -867,16 +867,14 @@ gboolean rofi_theme_parse_file ( const char *file ) yyin = NULL; while ( (po = g_queue_pop_head ( file_queue ) )) { - if ( po ) { - if ( po->type == PT_FILE ) { - fclose ( po->filein ); - } - if ( po->type == PT_STRING_ALLOC ) { - g_free( po->malloc_str); - } - g_free ( po->filename ); - g_free ( po ); - } + if ( po->type == PT_FILE ) { + fclose ( po->filein ); + } + if ( po->type == PT_STRING_ALLOC ) { + g_free( po->malloc_str); + } + g_free ( po->filename ); + g_free ( po ); } // Free up. g_queue_free ( file_queue ); @@ -904,16 +902,14 @@ gboolean rofi_theme_parse_string ( const char *string ) yylex_destroy (); while ( (po = g_queue_pop_head ( file_queue ) )) { - if ( po ) { - if ( po->type == PT_FILE ) { - fclose ( po->filein ); - } - if ( po->type == PT_STRING_ALLOC ) { - g_free( po->malloc_str); - } - g_free ( po->filename ); - g_free ( po ); - } + if ( po->type == PT_FILE ) { + fclose ( po->filein ); + } + if ( po->type == PT_STRING_ALLOC ) { + g_free( po->malloc_str); + } + g_free ( po->filename ); + g_free ( po ); } // Free up. g_queue_free ( file_queue ); diff --git a/source/helper.c b/source/helper.c index 59539ef8..e9bf3a76 100644 --- a/source/helper.c +++ b/source/helper.c @@ -785,15 +785,6 @@ char *rofi_latin_to_utf8_strdup(const char *input, gssize length) { NULL, &slength, NULL); } -gchar *rofi_escape_markup(gchar *text) { - if (text == NULL) { - return NULL; - } - gchar *ret = g_markup_escape_text(text, -1); - g_free(text); - return ret; -} - char *rofi_force_utf8(const gchar *data, ssize_t length) { if (data == NULL) { return NULL; diff --git a/source/theme.c b/source/theme.c index d8a33418..8d10fbff 100644 --- a/source/theme.c +++ b/source/theme.c @@ -1247,9 +1247,9 @@ rofi_theme_get_highlight_inside(Property *p, widget *widget, } else { ThemeWidget *wid = rofi_theme_find_widget(widget->name, widget->state, FALSE); - Property *p = rofi_theme_find_property(wid, P_COLOR, property, FALSE); - if (p != NULL) { - return rofi_theme_get_highlight_inside(p, widget, property, th); + Property *p2 = rofi_theme_find_property(wid, P_COLOR, property, FALSE); + if (p2 != NULL) { + return rofi_theme_get_highlight_inside(p2, widget, property, th); } return th; } @@ -1350,16 +1350,6 @@ void distance_get_linestyle(RofiDistance d, cairo_t *draw) { } } -gboolean rofi_theme_is_empty(void) { - if (rofi_theme == NULL) { - return TRUE; - } - if (rofi_theme->properties == NULL && rofi_theme->num_widgets == 0) { - return TRUE; - } - return FALSE; -} - char *rofi_theme_parse_prepare_file(const char *file, const char *parent_file) { char *filename = rofi_expand_path(file); // If no absolute path specified, expand it. diff --git a/source/widgets/listview.c b/source/widgets/listview.c index 8605f2d2..b5c02231 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -946,12 +946,6 @@ void listview_set_num_lines(listview *lv, unsigned int num_lines) { } } -unsigned int listview_get_num_lines(listview *lv) { - if (lv) { - return lv->menu_lines; - } - return 0; -} void listview_set_max_lines(listview *lv, unsigned int max_lines) { if (lv) { lv->max_displayed_lines = max_lines; diff --git a/source/widgets/widget.c b/source/widgets/widget.c index 3eb5debd..040cc243 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -128,13 +128,6 @@ void widget_set_type(widget *widget, WidgetType type) { widget->type = type; } -WidgetType widget_type(widget *widget) { - if (widget == NULL) { - return WIDGET_TYPE_UNKNOWN; - } - return widget->type; -} - gboolean widget_enabled(widget *widget) { if (widget == NULL) { return FALSE; @@ -548,8 +541,8 @@ widget *widget_find_mouse_target(widget *wid, WidgetType type, gint x, gint y) { return NULL; } -WidgetTriggerActionResult widget_check_action(widget *wid, guint action, - gint x, gint y) { +WidgetTriggerActionResult widget_check_action(widget *wid, guint action, gint x, + gint y) { if (wid == NULL) { return FALSE; }