[GRASS-dev] help with r.le.setup bug

Glynn Clements glynn at gclements.plus.com
Fri Oct 6 16:56:51 EDT 2006

Glynn Clements wrote:

> > > > I think it's a simple type mismatch in variables getting passed to a
> > > > function.
> > 
> > > It is. ux/uy are arrays of ints but calc_unit_loc() expects arrays of
> > > doubles.
> > > 
> > > Try the attached patch.
> > 
> > [also cast to int for overlap() fn]
> > 
> > yes, thanks.  funny, even with your patch it still messes up the "y"
> > values of draw_box() unless I add in the fn prototype to setup.h.
> Right. overlap() expects "int"s, but some of the values passed are
> changed to double by my patch. If a valid prototype is in scope, the
> compiler will automatically cast them to int, otherwise it will pass
> them as double.
> All of those declarations in setup.h should be either fixed or
> removed. If the compiler needs a prototype (because the function isn't
> already in scope at the point that it's used), it needs the *correct*
> prototype.

I've cleaned up r.le.setup. All of the functions have correct
prototypes, and any which aren't used outside of the file in which
they are defined have been declared "static". Also, I've removed the
local copy of the <dirent.h> stuff.

There is one warning which may indicate an error:

sample.c:826: warning: suggest parentheses around assignment used as truth value

which relates to:

	   if (n = i % h_d)

I don't know enough about the code to determine whether this is meant
to be an assignment or a comparison.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list