Two identical "else if" blocks ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Two identical "else if" blocks ?

Joel Brobecker
Hello,

While reviewing everyone comments regarding the patch for catching
Ada exceptions, I noticed the following code in remove_breakpoint:

  else if ((b->owner->type == bp_catch_catch ||
            b->owner->type == bp_catch_throw)
           && breakpoint_enabled (b->owner)
           && !b->duplicate)
    {
      val = target_remove_breakpoint (&b->target_info);
      if (val)
        return val;
      b->inserted = (is == mark_inserted);
    }
  else if (ep_is_exception_catchpoint (b->owner)
           && b->inserted       /* sometimes previous insert doesn't happen */
           && breakpoint_enabled (b->owner)
           && !b->duplicate)
    {
      val = target_remove_breakpoint (&b->target_info);
      if (val)
        return val;

      b->inserted = (is == mark_inserted);
    }

Since ep_is_exception_catchpoint is:

  return (ep->type == bp_catch_catch) || (ep->type == bp_catch_throw);

It looks like the two blocks are completely identical, and we should
be able to remove one of them. Should I perhaps test what happens
when I delete, say, the first one?

--
Joel
Reply | Threaded
Open this post in threaded view
|

Re: Two identical "else if" blocks ?

Daniel Jacobowitz-2
On Mon, Jan 01, 2007 at 07:52:49AM +0400, Joel Brobecker wrote:
> It looks like the two blocks are completely identical, and we should
> be able to remove one of them. Should I perhaps test what happens
> when I delete, say, the first one?

They're not 100% the same (there's an extra b->inserted check) so I'd
recommend deleting the second one, since it's dead code.

Looks like they've been the same since at least the dawn of CVS.

--
Daniel Jacobowitz
CodeSourcery
Reply | Threaded
Open this post in threaded view
|

[commit] (was: "Re: Two identical "else if" blocks ?")

Joel Brobecker
> > It looks like the two blocks are completely identical, and we should
> > be able to remove one of them. Should I perhaps test what happens
> > when I delete, say, the first one?
>
> They're not 100% the same (there's an extra b->inserted check) so I'd
> recommend deleting the second one, since it's dead code.

Argh! I knew I had a blind spot :-/.

I've checked the following change in after having tested in on x86-linux.

2006-01-01  Joel Brobecker  <[hidden email]>

       * breakpoint.c (remove_breakpoint): Remove dead code.

--
Joel

dead.diff (778 bytes) Download Attachment