[GRASS-dev] is this compiler-safe?
Markus Metz
markus.metz.giswork at googlemail.com
Wed Feb 10 09:45:11 EST 2010
Glynn Clements wrote:
>
> I would use:
>
> static int write_int(int fd, int n)
> {
> if (write(fd, &n, sizeof(int)) != sizeof(int)) {
> G_warning("%s", strerror(errno));
> return 0;
> }
>
> return 1;
> }
>
>
>
fixed in trunk r40910, devbr r40911 and relbr r40912
> While you're there, can you fix this nonsense:
>
> if (file_size > INT_MAX) {
> ?
>
also fixed, removed
Any suggestions on how to compute required file size on 32bit OS with
sizeof(off_t) = 4 ?
e.g.
(double) nrows * ncols * sizeof(DCELL)
or
(long long int) nrows * ncols * sizeof(DCELL)
more generic
number_of_items * sizeof(item)
and safely compare that to 2^31 (2GB)?
the segment library and the vector libs in grass7 would need such a test.
Thanks,
Markus M
More information about the grass-dev
mailing list