Hello Neil,

Neil Williams schrieb am Sun 13. Aug, 22:56 (+0100):
> Jörg Sommer wrote:
>
> I see now you mentioned originally:
> > compiling gnucash with -Wall and -Wextra brings some warnings like this:
> 
> So, here's a new start for this bug:
> 1. -Wall is already set, don't set it again.

OK, but this should not change anything.

> 2. -Wextra is *not supported* by gnucash and errors are to be expected.
> Don't use it.

-Wextra does not generate any errors. It warns about common cases where
errors can araise.

> > Because the build log is really big (3.7MB) I put it at
> > http://www.minet.uni-jena.de/~joergs/gc.build.log
> 
> Compare with the Debian build log for powerpc:
> 
> http://buildd.debian.org/fetch.php?&pkg=gnucash&ver=2.0.1-1&arch=powerpc&stamp=1155098349&file=log&as=raw
> 
> You only have a problem because of extra compiler flags

I don't have a problem. I point out some sources of problems before they
arise.

For example, look at gnc-date.c:234. The function name timespec_abs()
suggests the value should be made a positive value, if it's negative. But
the comparison "retval.tv_sec < 0" is always false, due to tv_sec is
unsigned according gnc-date.h:
,----
|  * struct timespec64 is just like the unix 'struct timespec' except 
|  * that we use a 64-bit
|  * unsigned int to store the seconds.  This should adequately cover
|  …
|  typedef struct timespec64 Timespec;
`----

So, somehere you assign an negative value to tv_sec of type (unsigned)
int. The timespec_abs() function interprets this (signed) negativ value
as (unsigned) positiv value—you know, (unsigned int)-1 == UINT_MAX. This
function, except of the call of timespec_normalize()—which also makes
mistakes—is a big noop.

Or look at fin.c:1212
,----
| static double
| rnd (double x, unsigned places)
| {
|  …
|   if (places >= 0)
|   {
|     sprintf (buf, "%.*f", (int) places, x);
|  …
|   else
`----

Isn't it stupid to check a non‐negativ value, if it is greater or equal
zero? This holds everytime.

This may not lead to an error and gcc removes such unreachable parts, but
somewhere might be an assignment of an negative value to this
variable/parameter, which than results in a really curious call of
sprintf()—the case that should be prevented with the check.

Bye, Jörg.
-- 
Fuchs' Paradoxon (http://www.bruhaha.de/laws.html):
Wer eine allgemeine Frage beliebigen Themas nach de.alt.arnooo postet und
eine ernsthafte Antwort erwartet, ist dort eigentlich ziemlich ontopic.

Attachment: pgppq7k7gRRtm.pgp
Description: PGP signature

Reply via email to