RE: [PATCH v10 25/28] btrace, gdbserver: read branch trace incrementally

Metzger, Markus T
2014-01-17T08:28:38Z

> -----Original Message-----
> From: Tom Tromey [mailto:tromey@redhat.com]
> Sent: Thursday, January 16, 2014 6:57 PM

> Markus> -VEC (btrace_block_s) *
> Markus> -target_read_btrace (struct btrace_target_info *btinfo,
> Markus> +enum btrace_error
> Markus> +target_read_btrace (VEC (btrace_block_s) **btrace,
> Markus> + struct btrace_target_info *btinfo,
> Markus> enum btrace_read_type type)
> Markus> {
> Markus> struct target_ops *t;
>
> Markus> for (t = current_target.beneath; t != NULL; t = t->beneath)
> Markus> if (t->to_read_btrace != NULL)
> Markus> - return t->to_read_btrace (btinfo, type);
> Markus> + return t->to_read_btrace (btrace, btinfo, type);
>
> Markus> tcomplain ();
> Markus> - return NULL;
> Markus> + return BTRACE_ERR_NOT_SUPPORTED;
> Markus> }
>
> While rebasing my branch I noticed this code.
>
> tcomplain doesn't return, so the final "return" here will never be
> executed.
>
> Given the function's history I assume this is no big deal -- just a
> small oversight, compounded by the compiler not bothering to tell us
> that it knows about this :)
>
> However I wanted to point it out in case you were expecting an error
> return here.

I am expecting the exception from tcomplain ().

The return BTRACE_ERR_NOT_SUPPORTED is to avoid warnings from
compilers that can't figure out that tcomplain () does not return.

I used to return NULL before and I'm using the same pattern in
target_enable_btrace. There's another instance in dummy_get_bookmark.

If this turns out to be unnecessary, I can send a patch to remove
those extra returns.

Regards,
Markus.

Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052