[GRASS-dev] Re: About the vector changes

Glynn Clements glynn at gclements.plus.com
Sat Aug 8 19:24:46 EDT 2009


Markus Neteler wrote:

> >> I got carried away (replacing all fseek/ftell occurrences I could find
> >> with G_fseek/G_ftell, adjusting off_t as you showed above) and also made
> >> r3.in|out.v5d LFS-safe, but did not submit. Should I?
> >
> > Yes; ideally, we should use G_{fseek,ftell} everywhere.
> 
> Patch attached.
> 
> Note that it now fails to compile here:
> 
> make[1]: Entering directory `/home/neteler/grass70/lib/rst/interp_float'
> gcc -I/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/include
> -I/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/include  -g
> -Wall -Werror-implicit-function-declaration -fno-common -mtune=nocona
> -m64 -minline-all-stringops   -fPIC  -I/usr/local/include
> -D_FILE_OFFSET_BITS=64 -DPACKAGE=\""grasslibs"\"
> -I/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/include
> -I/home/neteler/grass70/dist.x86_64-unknown-linux-gnu/include -o
> OBJ.x86_64-unknown-linux-gnu/output2d.o -c output2d.c
> output2d.c: In function �IL_output_2d�:
> output2d.c:153: error: void value not ignored as it ought to be

> No clue how what could be wrong in the patch. Same problem in
> raster/r.in.xyz

fseek() returns a status code, but G_fseek() doesn't (it calls
G_fatal_error() if fseek() returns non-zero).

lib/rst should be changed to ignore the return value and let G_fseek()
signal an error.

r.in.xyz actually needs the return value, as it can handle
non-seekable streams (e.g. pipes).

It might be possible to keep the fseek(), as it only ever passes an
offset of zero (to seek to either the beginning or end of the file);
it depends upon whether fseek(fp,0,SEEK_END) works if the file is
>2GiB.

Alternatively, we may need a G__fseek() which returns the status
rather than calling G_fatal_error().

In any case, the ftell() call needs to be changed to G_ftell().

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list