Fix tui compilation with Solaris libcurses: non-const last arg to mvwaddstr (PR tui...
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Fri, 19 May 2017 12:16:55 +0000 (14:16 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Fri, 19 May 2017 12:16:55 +0000 (14:16 +0200)
On both mainline and the 8.0 branch, gdb compilation fails on Solaris 10
with the native libcurses in gdb/tui for several instances of the same problem:

/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c: In function `void tui_erase_source_content(tui_win_info*, int)':
/vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c:257:18: error: invalid conversion from `const char*' to `char*' [-fpermissive]
        no_src_str);
                  ^
In file included from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/gdb_curses.h:42:0,
                 from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-data.h:26,
                 from /vol/src/gnu/gdb/gdb-8.0-branch/local/gdb/tui/tui-winsource.c:33:
/vol/gcc-7/lib/gcc/sparc-sun-solaris2.10/7.1.0/include-fixed/curses.h:699:12: note:   initializing argument 4 of `int mvwaddstr(WINDOW*, int, int, char*)'
 extern int mvwaddstr(WINDOW *, int, int, char *);
            ^~~~~~~~~
make[2]: *** [Makefile:1927: tui-winsource.o] Error 1

Unlike ncurses, <curses.h> declares

extern int mvwaddstr(WINDOW *, int, int, char *);

i.e. the last arg is char *, not const char *.

The patch fixes this by casting the last arg to mvwaddstr to char *,
as was recently done on mainline in a newterm() call (the only
difference between 8.0 and mainline gdb/tui).

* tui/tui-windata.c (tui_erase_data_content): Cast last mvwaddstr
arg to char *.
* tui/tui-wingeneral.c (box_win): Likewise.
* tui/tui-winsource.c (tui_erase_source_content): Likewise.
(tui_show_source_line): Likewise.
(tui_show_exec_info_content): Likewise.

gdb/ChangeLog
gdb/tui/tui-windata.c
gdb/tui/tui-wingeneral.c
gdb/tui/tui-winsource.c

index 1273ed89c737a1b28ccd8ffaa547d5f8fd2c3f8e..6bffa90ba1949b6e7afa0b73076abebd2c449002 100644 (file)
@@ -1,3 +1,12 @@
+2017-05-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * tui/tui-windata.c (tui_erase_data_content): Cast last mvwaddstr
+       arg to char *.
+       * tui/tui-wingeneral.c (box_win): Likewise.
+       * tui/tui-winsource.c (tui_erase_source_content): Likewise.
+       (tui_show_source_line): Likewise.
+       (tui_show_exec_info_content): Likewise.
+
 2017-05-19  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
 
        * sparc-tdep.c (sparc_structure_return_p)
index 8e7d55c420532ba413bd0523839359aa01d991fd..e7571e632c803ad4c5652c3c59d6d56daea40003 100644 (file)
@@ -117,7 +117,7 @@ tui_erase_data_content (const char *prompt)
       mvwaddstr (TUI_DATA_WIN->generic.handle,
                 (TUI_DATA_WIN->generic.height / 2),
                 x_pos,
-                prompt);
+                (char *) prompt);
     }
   wrefresh (TUI_DATA_WIN->generic.handle);
 }
index 16b466ddff2bc9552c4927ceeff9e52bc696f530..5dd2c01bcac44b6da5e75070738d36963183bcb1 100644 (file)
@@ -101,7 +101,7 @@ box_win (struct tui_gen_win_info *win_info,
       box (win, tui_border_vline, tui_border_hline);
 #endif
       if (win_info->title)
-        mvwaddstr (win, 0, 3, win_info->title);
+        mvwaddstr (win, 0, 3, (char *) win_info->title);
       wattroff (win, attrs);
     }
 }
index 73ad93f324a31928e4c914d6ae74a5053be4bf1f..3ae9c7122992619b6767d1ba91956b90d707cfc6 100644 (file)
@@ -254,7 +254,7 @@ tui_erase_source_content (struct tui_win_info *win_info,
          mvwaddstr (win_info->generic.handle,
                     (win_info->generic.height / 2),
                     x_pos,
-                    no_src_str);
+                    (char *) no_src_str);
 
          /* elz: Added this function call to set the real contents of
             the window to what is on the screen, so that later calls
@@ -280,7 +280,7 @@ tui_show_source_line (struct tui_win_info *win_info, int lineno)
     wattron (win_info->generic.handle, A_STANDOUT);
 
   mvwaddstr (win_info->generic.handle, lineno, 1,
-             line->which_element.source.line);
+             (char *) line->which_element.source.line);
   if (line->which_element.source.is_exec_point)
     wattroff (win_info->generic.handle, A_STANDOUT);
 
@@ -565,7 +565,8 @@ tui_show_exec_info_content (struct tui_win_info *win_info)
     mvwaddstr (exec_info->handle,
               cur_line,
               0,
-              exec_info->content[cur_line - 1]->which_element.simple_string);
+              (char *) exec_info->content[cur_line - 1]
+                         ->which_element.simple_string);
   tui_refresh_win (exec_info);
   exec_info->content_in_use = TRUE;
 }