r23494 - gnucash/trunk/src - Test for overflow limits in gnc_numeric_add.

Geert Janssens janssens-geert at telenet.be
Sat Dec 7 10:41:25 EST 2013


On Thursday 05 December 2013 16:54:28 John Ralls wrote:
> Author: jralls
> Date: 2013-12-05 16:54:28 -0500 (Thu, 05 Dec 2013)
> New Revision: 23494
> Trac: http://svn.gnucash.org/trac/changeset/23494
> 
> Added:
>    gnucash/trunk/src/libqof/qof/test/test-gnc-numeric.c
> Modified:
>    gnucash/trunk/src/engine/test/test-numeric.c
>    gnucash/trunk/src/libqof/qof/gnc-numeric.c
> Log:
> Test for overflow limits in gnc_numeric_add.
> 
> For analysis of Bug 665707.
> 
<snip>
> 
> Modified: gnucash/trunk/src/libqof/qof/gnc-numeric.c
> 
==========================================================
=========
> --- gnucash/trunk/src/libqof/qof/gnc-numeric.c	2013-12-05 21:54:18 UTC
> (rev 23493) +++ gnucash/trunk/src/libqof/qof/gnc-numeric.c	2013-12-05
> 21:54:28 UTC (rev 23494) @@ -45,6 +45,23 @@
> 
>  /* static short module = MOD_ENGINE; */
> 
> +gint64
> +pwr64 (gint64 op, int exp)
> +{
> +    qofint128 tmp;
> +    if (exp == 0) return 1;
> +    if (exp % 2)
> +    {
> +	tmp = mult128 (op, pwr64 (op, exp - 1));
> +	if (tmp.isbig) return 0;
> +	return tmp.lo;
> +    }
> +    tmp.lo = pwr64 (op, exp / 2);
> +    tmp = mult128 (tmp.lo, tmp.lo);
> +    if (tmp.isbig) return 0;
> +    return tmp.lo;
> +}
> +

This addition breaks the build on my machine with error:
no previous prototype for 'pwr64' [-Werror=missing-prototypes]
 pwr64 (gint64 op, int exp)

Geert


More information about the gnucash-devel mailing list