Bugs (?) in gnc-pricedb.c

Andrew Sackville-West andrew at farwestbilliards.com
Mon Feb 20 12:09:41 EST 2006


On Mon, 20 Feb 2006 03:55:19 -0500
Mike Alexander <mta at umich.edu> wrote:

> --On February 19, 2006 2:01:01 PM -0800 Andrew Sackville-West 
> <andrew at farwestbilliards.com> wrote:
> 
> > On Wed, 08 Feb 2006 02:50:47 -0500
> > Mike Alexander <mta at umich.edu> wrote:
> >
> >> While looking for another problem I found what look like bugs in a
> >> couple of functions [1] in gnc-pricedb.c.  It appears to me that the
> >> loop termination test is backwards in a couple of places.  I've
> >> attached a patch that fixes this (if it is indeed a problem).
> >>
> >> I added a number of patches to bug reports, but since I don't know
> >> how  to cause this bug to occur I didn't create a bug report for it.
> >>
> >> [1] gnc_pricedb_convert_balance_latest_price and
> >> gnc_pricedb_convert_balance_nearest_price.
> >
> > Hampton,
> >
> > I see other problems with these functions...
> > for ex: if (!price-list) { balance = gnc_numeric_zero; return
> > balance;};
> >
> > well, that just doesn'tdoens't make sense. just because there is no
> > price-list we return a 0 for the balance? granted the function has
> > pricedb in the name and so its reasonable to assume there is a
> > pricelist, but how do you distinguish between a no price-list
> > situation and a balance that is actually zero?
> 
> I found another problem in this code tonight.  The price lookup 
> functions try to handle the case of converting currency1 into currency2 
> if the pricedb contains an exchange rate for currency2->currency1 but 
> not vice versa (by using the reciprocal).  It did it right in the hard 
> case where you give it a commodity priced in currency1 and ask for the 
> value in currency2, but not for the easier case where you give it a 
> value in currency1 and ask for it in currency2.  The attached patch 
> makes it handle that case too.  It also contains the previous loop 
> termination patch, which I'm now quite sure is correct.  It does not do 
> anything about the bug you mentioned above since I didn't see this 
> message until after I was done with this.

Well I'm not sure its a bug, just jumped out at me on my frist
readthrough of that code. 

have you been following the advanced-portfolio thread?

A
> 
> -- 
> Mike Alexander           mta at umich.edu
> Ann Arbor, MI            PGP key ID: BEA343A6
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.gnucash.org/pipermail/gnucash-devel/attachments/20060220/7f88d324/attachment.bin


More information about the gnucash-devel mailing list