[RFA,16/42] Use gdb_assert in two places in buildsym.c

Message ID 20180523045851.11660-17-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey May 23, 2018, 4:58 a.m. UTC
  This changes buildsym.c to use gdb_assert rather than internal_error
in a couple of spots.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (push_subfile): Use gdb_assert.
	(pop_subfile): Use gdb_assert.
---
 gdb/ChangeLog  |  5 +++++
 gdb/buildsym.c | 12 ++----------
 2 files changed, 7 insertions(+), 10 deletions(-)
  

Comments

Simon Marchi July 8, 2018, 4:55 p.m. UTC | #1
On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This changes buildsym.c to use gdb_assert rather than internal_error
> in a couple of spots.

Just a nit, but I think inverting the condition would be more readable

  gdb_assert (current_subfile != NULL && current_subfile->name != NULL);

LGTM either way.

Simon
  
Tom Tromey July 9, 2018, 11:08 p.m. UTC | #2
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> Just a nit, but I think inverting the condition would be more readable
Simon>   gdb_assert (current_subfile != NULL && current_subfile->name != NULL);
Simon> LGTM either way.

I did this.

Tom
  

Patch

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 4744d510c3..4823fb383d 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -896,11 +896,7 @@  push_subfile (void)
 
   tem->next = subfile_stack;
   subfile_stack = tem;
-  if (current_subfile == NULL || current_subfile->name == NULL)
-    {
-      internal_error (__FILE__, __LINE__, 
-		      _("failed internal consistency check"));
-    }
+  gdb_assert (! (current_subfile == NULL || current_subfile->name == NULL));
   tem->name = current_subfile->name;
 }
 
@@ -910,11 +906,7 @@  pop_subfile (void)
   char *name;
   struct subfile_stack *link = subfile_stack;
 
-  if (link == NULL)
-    {
-      internal_error (__FILE__, __LINE__,
-		      _("failed internal consistency check"));
-    }
+  gdb_assert (link != NULL);
   name = link->name;
   subfile_stack = link->next;
   xfree ((void *) link);