[GRASS-dev] is this compiler-safe?
Markus Metz
markus.metz.giswork at googlemail.com
Wed Feb 10 06:22:54 EST 2010
Glynn Clements wrote:
> Actually, looking at the code in context, I'd write:
>
> static void write_int(int fd, int n)
> {
> if (write(fd, &n, sizeof(int)) != sizeof(int))
> G_fatal_error("%s", strerror(errno));
> }
>
> Lets face it: you aren't going to be recovering from this situation,
> are you? If _segment_format fails, the module fails.
>
Yup. Or worse, the module finishes and produces corrupt output. OTOH,
_segment_format() is supposed to return -1 on seek or write failure and
it's up to modules calling segment_format() or segment_format_nofill()
to check the return value.
> While you're there, can you fix this nonsense:
>
> if (file_size > INT_MAX) {
> ?
>
Sure, that should be handled by write() I guess.
> OTOH, the segment library is long overdue for being replaced with
> something more efficient.
>
Try grass7. Not a replacement but optimization.
More information about the grass-dev
mailing list