Change tui_alloc_source_buffer return type to void
authorTom Tromey <tom@tromey.com>
Sun, 16 Jun 2019 23:49:41 +0000 (17:49 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 25 Jun 2019 13:48:39 +0000 (07:48 -0600)
tui_alloc_source_buffer can't actually fail, so change its return type
to void and update the callers.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

* tui/tui-winsource.h (tui_alloc_source_buffer): Change return
type to void.
* tui/tui-winsource.c (tui_alloc_source_buffer): Change return
type to void.
* tui/tui-source.c (tui_set_source_content): Update.
* tui/tui-disasm.c (tui_set_disassem_content): Update.

gdb/ChangeLog
gdb/tui/tui-disasm.c
gdb/tui/tui-source.c
gdb/tui/tui-winsource.c
gdb/tui/tui-winsource.h

index fd95f6e2e2d54bf290e74a58ea539ebde0e0bce5..a97cfde736d8af85a0446080a91b9ce6e0de98e8 100644 (file)
@@ -1,3 +1,12 @@
+2019-06-25  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-winsource.h (tui_alloc_source_buffer): Change return
+       type to void.
+       * tui/tui-winsource.c (tui_alloc_source_buffer): Change return
+       type to void.
+       * tui/tui-source.c (tui_set_source_content): Update.
+       * tui/tui-disasm.c (tui_set_disassem_content): Update.
+
 2019-06-25  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-win.c (window_name_completer, tui_set_focus)
index a9d827f5b7877b0c0a39b90c626d82e0d103f011..0bc7c642bcd03ba4f7ff6540c023144ae7655f9c 100644 (file)
@@ -165,7 +165,6 @@ tui_find_disassembly_address (struct gdbarch *gdbarch, CORE_ADDR pc, int from)
 enum tui_status
 tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  enum tui_status ret = TUI_FAILURE;
   int i;
   int offset = TUI_DISASM_WIN->horizontal_offset;
   int max_lines, line_width;
@@ -180,9 +179,7 @@ tui_set_disassem_content (struct gdbarch *gdbarch, CORE_ADDR pc)
   if (pc == 0)
     return TUI_FAILURE;
 
-  ret = tui_alloc_source_buffer (TUI_DISASM_WIN);
-  if (ret != TUI_SUCCESS)
-    return ret;
+  tui_alloc_source_buffer (TUI_DISASM_WIN);
 
   tui_source_window_base *base = TUI_DISASM_WIN;
   base->gdbarch = gdbarch;
index c6367765d6786b15f75e379fdd656ed7af788349..39abe81a870c6b4a7b8033b516ef07ca83ca42fd 100644 (file)
@@ -133,86 +133,85 @@ tui_set_source_content (struct symtab *s,
     {
       int line_width, nlines;
 
-      if ((ret = tui_alloc_source_buffer (TUI_SRC_WIN)) == TUI_SUCCESS)
+      ret = TUI_SUCCESS;
+      tui_alloc_source_buffer (TUI_SRC_WIN);
+      line_width = TUI_SRC_WIN->width - 1;
+      /* Take hilite (window border) into account, when
+        calculating the number of lines.  */
+      nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no;
+
+      std::string srclines;
+      if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
+                                           &srclines))
        {
-         line_width = TUI_SRC_WIN->width - 1;
-         /* Take hilite (window border) into account, when
-            calculating the number of lines.  */
-         nlines = (line_no + (TUI_SRC_WIN->height - 2)) - line_no;
-
-         std::string srclines;
-         if (!g_source_cache.get_source_lines (s, line_no, line_no + nlines,
-                                               &srclines))
+         if (!noerror)
            {
-             if (!noerror)
-               {
-                 const char *filename = symtab_to_filename_for_display (s);
-                 char *name = (char *) alloca (strlen (filename) + 100);
-
-                 sprintf (name, "%s:%d", filename, line_no);
-                 print_sys_errmsg (name, errno);
-               }
-             ret = TUI_FAILURE;
+             const char *filename = symtab_to_filename_for_display (s);
+             char *name = (char *) alloca (strlen (filename) + 100);
+
+             sprintf (name, "%s:%d", filename, line_no);
+             print_sys_errmsg (name, errno);
            }
-         else
+         ret = TUI_FAILURE;
+       }
+      else
+       {
+         int cur_line_no, cur_line;
+         struct tui_gen_win_info *locator
+           = tui_locator_win_info_ptr ();
+         struct tui_source_window_base *src
+           = (struct tui_source_window_base *) TUI_SRC_WIN;
+         const char *s_filename = symtab_to_filename_for_display (s);
+
+         if (TUI_SRC_WIN->title)
+           xfree (TUI_SRC_WIN->title);
+         TUI_SRC_WIN->title = xstrdup (s_filename);
+
+         xfree (src->fullname);
+         src->fullname = xstrdup (symtab_to_fullname (s));
+
+         cur_line = 0;
+         src->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
+         src->start_line_or_addr.loa = LOA_LINE;
+         cur_line_no = src->start_line_or_addr.u.line_no = line_no;
+
+         const char *iter = srclines.c_str ();
+         while (cur_line < nlines)
            {
-             int cur_line_no, cur_line;
-             struct tui_gen_win_info *locator
-               = tui_locator_win_info_ptr ();
-             struct tui_source_window_base *src
-               = (struct tui_source_window_base *) TUI_SRC_WIN;
-             const char *s_filename = symtab_to_filename_for_display (s);
-
-             if (TUI_SRC_WIN->title)
-               xfree (TUI_SRC_WIN->title);
-             TUI_SRC_WIN->title = xstrdup (s_filename);
-
-             xfree (src->fullname);
-             src->fullname = xstrdup (symtab_to_fullname (s));
-
-             cur_line = 0;
-             src->gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s));
-             src->start_line_or_addr.loa = LOA_LINE;
-             cur_line_no = src->start_line_or_addr.u.line_no = line_no;
-
-             const char *iter = srclines.c_str ();
-             while (cur_line < nlines)
-               {
-                 struct tui_win_element *element
-                   = TUI_SRC_WIN->content[cur_line];
-
-                 std::string text;
-                 if (*iter != '\0')
-                   text = copy_source_line (&iter, cur_line_no,
-                                            src->horizontal_offset,
-                                            line_width);
-
-                 /* Set whether element is the execution point
-                    and whether there is a break point on it.  */
-                 element->which_element.source.line_or_addr.loa =
-                   LOA_LINE;
-                 element->which_element.source.line_or_addr.u.line_no =
-                   cur_line_no;
-                 element->which_element.source.is_exec_point =
-                   (filename_cmp (locator->content[0]
-                                  ->which_element.locator.full_name,
-                                  symtab_to_fullname (s)) == 0
-                    && cur_line_no
-                    == locator->content[0]
-                    ->which_element.locator.line_no);
-
-                 xfree (TUI_SRC_WIN->content[cur_line]
-                        ->which_element.source.line);
-                 TUI_SRC_WIN->content[cur_line]
-                   ->which_element.source.line
-                   = xstrdup (text.c_str ());
-
-                 cur_line++;
-                 cur_line_no++;
-               }
-             TUI_SRC_WIN->content_size = nlines;
-             ret = TUI_SUCCESS;
+             struct tui_win_element *element
+               = TUI_SRC_WIN->content[cur_line];
+
+             std::string text;
+             if (*iter != '\0')
+               text = copy_source_line (&iter, cur_line_no,
+                                        src->horizontal_offset,
+                                        line_width);
+
+             /* Set whether element is the execution point
+                and whether there is a break point on it.  */
+             element->which_element.source.line_or_addr.loa =
+               LOA_LINE;
+             element->which_element.source.line_or_addr.u.line_no =
+               cur_line_no;
+             element->which_element.source.is_exec_point =
+               (filename_cmp (locator->content[0]
+                              ->which_element.locator.full_name,
+                              symtab_to_fullname (s)) == 0
+                && cur_line_no
+                == locator->content[0]
+                ->which_element.locator.line_no);
+
+             xfree (TUI_SRC_WIN->content[cur_line]
+                    ->which_element.source.line);
+             TUI_SRC_WIN->content[cur_line]
+               ->which_element.source.line
+               = xstrdup (text.c_str ());
+
+             cur_line++;
+             cur_line_no++;
            }
+         TUI_SRC_WIN->content_size = nlines;
+         ret = TUI_SUCCESS;
        }
     }
   return ret;
index 1ec9cecdc9c9dac475fe5b87b71f0ccc7a15b8f4..209d33d6c998e1f9dcd5883d92d54d3c644cade1 100644 (file)
@@ -589,7 +589,7 @@ tui_update_exec_info (struct tui_win_info *win_info)
   tui_show_exec_info_content (win_info);
 }
 
-enum tui_status
+void
 tui_alloc_source_buffer (struct tui_win_info *win_info)
 {
   int i, line_width, max_lines;
@@ -608,8 +608,6 @@ tui_alloc_source_buffer (struct tui_win_info *win_info)
        win_info->content[i]->which_element.source.line
          = (char *) xmalloc (line_width);
     }
-
-  return TUI_SUCCESS;
 }
 
 
index 6f2dc3533f77e42914b432b06b773f811b67d4b1..ccc9ae5f68a211d59e0fc79ab4b5a7de17fa29ca 100644 (file)
@@ -59,7 +59,7 @@ extern void tui_erase_exec_info_content (struct tui_win_info *);
 extern void tui_clear_exec_info_content (struct tui_win_info *);
 extern void tui_update_exec_info (struct tui_win_info *);
 
-extern enum tui_status tui_alloc_source_buffer (struct tui_win_info *);
+extern void tui_alloc_source_buffer (struct tui_win_info *);
 extern int tui_line_is_displayed (int, 
                                  struct tui_win_info *, 
                                  int);