This is the mail archive of the
mailing list for the elfutils project.
Re: [patch] Fix a regression of dwfl_core_file_report retval
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 07 Nov 2013 16:56:23 +0100
- Subject: Re: [patch] Fix a regression of dwfl_core_file_report retval
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;
> > /* 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
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?