[patch] Fix a regression of dwfl_core_file_report retval
Jan Kratochvil
jan.kratochvil at redhat.com
Thu Nov 7 15:56:23 UTC 2013
On Tue, 05 Nov 2013 22:07:01 +0100, Mark Wielaard wrote:
> On Fri, Nov 01, 2013 at 04:41:40PM +0100, Jan Kratochvil wrote:
> > + int listed = MAX (0, retval);
>
> Nitpick. I would find the following slightly clearer.
>
> int listed = retval > 0 ? retval : 0;
Done.
> > /* We return the number of modules we found if we found any.
> > If we found none, we return -1 instead of 0 if there was an
> > error rather than just nothing found. */
> > - return sniffed || listed >= 0 ? listed + sniffed : listed;
> > + return listed > 0 ? listed : retval;
>
> The comment doesn't match anymore when retval == 0.
> This looks simpler:
>
> return listed > 0 ? listed : -1;
The comment is right and the code in my patch is also right. You broke it.
dwfl_link_map_report returns > 0 if it found any modules.
dwfl_link_map_report returns 0 if no error happened but just no valid new
modules were reported. Still for example
module candidates could be stored into
struct r_debug_info.
dwfl_link_map_report returns -1 if an error happened, such as unreadable
address in memory.
So I would leave it as is, do you agree?
Jan
More information about the elfutils-devel
mailing list