Ticket #3598: cleanup some -Wcast-qual compiler warnings.

Introduce CONST_WIDGET helper and use it.

Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andreas Mohr 2016-02-20 14:29:21 +00:00 committed by Andrew Borodin
parent 51d0783bf9
commit 16f229114a
11 changed files with 31 additions and 28 deletions

View File

@ -201,7 +201,7 @@ dlg_unfocus (WDialog * h)
static int
dlg_find_widget_callback (const void *a, const void *b)
{
const Widget *w = WIDGET (a);
const Widget *w = CONST_WIDGET (a);
widget_cb_fn f = (widget_cb_fn) b;
return (w->callback == f) ? 0 : 1;
@ -595,7 +595,7 @@ frontend_dlg_run (WDialog * h)
static int
dlg_find_widget_by_id (gconstpointer a, gconstpointer b)
{
Widget *w = WIDGET (a);
const Widget *w = CONST_WIDGET (a);
unsigned long id = GPOINTER_TO_UINT (b);
return w->id == id ? 0 : 1;

View File

@ -281,7 +281,7 @@ widget_erase (Widget * w)
gboolean
widget_is_active (const void *w)
{
return (w == WIDGET (w)->owner->current->data);
return (w == CONST_WIDGET (w)->owner->current->data);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -12,8 +12,9 @@
/*** typedefs(not structures) and defined constants **********************************************/
#define WIDGET(x) ((Widget *)(x))
#define CONST_WIDGET(x) ((const Widget *)(x))
#define widget_move(w, _y, _x) tty_gotoyx (WIDGET(w)->y + (_y), WIDGET(w)->x + (_x))
#define widget_move(w, _y, _x) tty_gotoyx (CONST_WIDGET(w)->y + (_y), CONST_WIDGET(w)->x + (_x))
/* Sets/clear the specified flag in the options field */
#define widget_want_cursor(w,i) widget_set_options(w, W_WANT_CURSOR, i)
#define widget_want_hotkey(w,i) widget_set_options(w, W_WANT_HOTKEY, i)

View File

@ -1487,7 +1487,7 @@ edit_syntax_onoff_cb (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor ((const Widget *) data))
if (edit_widget_is_editor (CONST_WIDGET (data)))
{
WEdit *edit = (WEdit *) data;
@ -1511,7 +1511,7 @@ edit_redraw_page_cb (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor ((const Widget *) data))
if (edit_widget_is_editor (CONST_WIDGET (data)))
((WEdit *) data)->force |= REDRAW_PAGE;
}
@ -2244,7 +2244,7 @@ edit_close_cmd (WEdit * edit)
del_widget (edit);
if (edit_widget_is_editor (WIDGET (h->current->data)))
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
edit = (WEdit *) h->current->data;
else
{

View File

@ -346,7 +346,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, gboolean c
char *
editcmd_dialog_completion_show (const WEdit * edit, int max_len, GString ** compl, int num_compl)
{
const Widget *we = WIDGET (edit);
const Widget *we = CONST_WIDGET (edit);
int start_x, start_y, offset, i;
char *curr = NULL;
WDialog *compl_dlg;

View File

@ -348,7 +348,7 @@ edit_status_window (WEdit * edit)
static inline void
edit_draw_frame (const WEdit * edit, int color, gboolean active)
{
const Widget *w = (const Widget *) edit;
const Widget *w = CONST_WIDGET (edit);
/* draw a frame around edit area */
tty_setcolor (color);
@ -374,7 +374,7 @@ edit_draw_frame (const WEdit * edit, int color, gboolean active)
static inline void
edit_draw_window_icons (const WEdit * edit, int color)
{
const Widget *w = WIDGET (edit);
const Widget *w = CONST_WIDGET (edit);
char tmp[17];
tty_setcolor (color);

View File

@ -84,7 +84,7 @@ edit_reset_over_col (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor ((const Widget *) data))
if (edit_widget_is_editor (CONST_WIDGET (data)))
((WEdit *) data)->over_col = 0;
}
@ -102,9 +102,10 @@ edit_reload_syntax (void *data, void *user_data)
{
(void) user_data;
if (edit_widget_is_editor (WIDGET (data)))
if (edit_widget_is_editor (CONST_WIDGET (data)))
{
WEdit *edit = (WEdit *) data;
edit_load_syntax (edit, NULL, edit->syntax_type);
}
}

View File

@ -332,7 +332,7 @@ edit_window_list (const WDialog * h)
listbox = create_listbox_window (lines, cols, _("Open files"), "[Open files]");
for (w = h->widgets; w != NULL; w = g_list_next (w))
if (edit_widget_is_editor (WIDGET (w->data)))
if (edit_widget_is_editor (CONST_WIDGET (w->data)))
{
WEdit *e = (WEdit *) w->data;
char *fname;
@ -427,7 +427,7 @@ edit_dialog_command_execute (WDialog * h, long command)
break;
case CK_Close:
/* if there are no opened files anymore, close MC editor */
if (edit_widget_is_editor (WIDGET (h->current->data)) &&
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)) &&
edit_close_cmd ((WEdit *) h->current->data) && find_editor (h) == NULL)
dlg_stop (h);
break;
@ -476,7 +476,7 @@ edit_dialog_command_execute (WDialog * h, long command)
break;
case CK_WindowMove:
case CK_WindowResize:
if (edit_widget_is_editor (WIDGET (h->current->data)))
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
edit_handle_move_resize ((WEdit *) h->current->data, command);
break;
case CK_WindowList:
@ -643,7 +643,7 @@ edit_quit (WDialog * h)
h->state = DLG_ACTIVE; /* don't stop the dialog before final decision */
for (l = h->widgets; l != NULL; l = g_list_next (l))
if (edit_widget_is_editor (WIDGET (l->data)))
if (edit_widget_is_editor (CONST_WIDGET (l->data)))
{
e = (WEdit *) l->data;
@ -890,7 +890,8 @@ edit_dialog_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event)
/* Try find top fullscreen window */
for (l = h->widgets; l != NULL; l = g_list_next (l))
if (edit_widget_is_editor (WIDGET (l->data)) && ((WEdit *) l->data)->fullscreen)
if (edit_widget_is_editor (CONST_WIDGET (l->data))
&& ((WEdit *) l->data)->fullscreen)
top = l;
/* Handle fullscreen/close buttons in the top line */
@ -1266,7 +1267,7 @@ edit_get_file_name (const WEdit * edit)
WEdit *
find_editor (const WDialog * h)
{
if (edit_widget_is_editor (WIDGET (h->current->data)))
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
return (WEdit *) h->current->data;
return (WEdit *) find_widget_type (h, edit_callback);
}

View File

@ -1139,7 +1139,7 @@ configure_vfs (void)
char *
cd_dialog (void)
{
const Widget *w = WIDGET (current_panel);
const Widget *w = CONST_WIDGET (current_panel);
char *my_str;
quick_widget_t quick_widgets[] = {

View File

@ -1228,7 +1228,7 @@ find_rotate_dash (const WDialog * h, gboolean show)
{
static size_t pos = 0;
static const char rotating_dash[4] = "|/-\\";
const Widget *w = WIDGET (h);
const Widget *w = CONST_WIDGET (h);
if (!verbose)
return;
@ -1458,7 +1458,7 @@ view_edit_currently_selected_file (gboolean unparsed_view, gboolean edit)
static void
find_calc_button_locations (const WDialog * h, gboolean all_buttons)
{
const int cols = WIDGET (h)->cols;
const int cols = CONST_WIDGET (h)->cols;
int l1, l2;
@ -1489,7 +1489,7 @@ find_relocate_buttons (const WDialog * h, gboolean all_buttons)
find_calc_button_locations (h, all_buttons);
for (i = 0; i < fbuts_num; i++)
fbuts[i].button->x = WIDGET (h)->x + fbuts[i].x;
fbuts[i].button->x = CONST_WIDGET (h)->x + fbuts[i].x;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -405,7 +405,7 @@ static int
panel_lines (const WPanel * p)
{
/* 3 lines are: top frame, column header, botton frame */
return (WIDGET (p)->lines - 3 - (panels_options.show_mini_info ? 2 : 0));
return (CONST_WIDGET (p)->lines - 3 - (panels_options.show_mini_info ? 2 : 0));
}
/* --------------------------------------------------------------------------------------------- */
@ -1066,7 +1066,7 @@ paint_dir (WPanel * panel)
static void
display_total_marked_size (const WPanel * panel, int y, int x, gboolean size_only)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
char buffer[BUF_SMALL], b_bytes[BUF_SMALL], *buf;
int cols;
@ -1112,7 +1112,7 @@ mini_info_separator (const WPanel * panel)
{
if (panels_options.show_mini_info)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
int y;
y = panel_lines (panel) + 2;
@ -1155,7 +1155,7 @@ show_free_space (const WPanel * panel)
if (myfs_stats.avail != 0 || myfs_stats.total != 0)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
char buffer1[6], buffer2[6], tmp[BUF_SMALL];
size_trunc_len (buffer1, sizeof (buffer1) - 1, myfs_stats.avail, 1,
@ -1256,7 +1256,7 @@ panel_get_encoding_info_str (const WPanel * panel)
static void
show_dir (const WPanel * panel)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
gchar *tmp;
@ -1554,7 +1554,7 @@ panel_get_title_without_hotkey (const char *title)
static void
panel_print_header (const WPanel * panel)
{
Widget *w = WIDGET (panel);
const Widget *w = CONST_WIDGET (panel);
int y, x;
int i;