[GRASS-dev] is this compiler-safe?

Markus Metz markus.metz.giswork at googlemail.com
Wed Feb 10 04:50:56 EST 2010


I found two code snippets in the segment library (all branches) that 
look fishy to me:

the first is in relbr6 here
https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/lib/segment/format.c#L135

should
    if (lseek(fd, 0L, SEEK_SET) == (off_t) - 1) {

not be
    if (lseek(fd, 0L, SEEK_SET) == (off_t) -1) {

because I can't see where 1 is subtracted from? Introduced with 
automated indentation in r32527

the second is in relbr6 here:
https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/lib/segment/format.c#L178

    if ((bytes_wrote = write(fd, &x, sizeof(int)) == sizeof(int)) < 0)

I am missing parentheses somewhere and would rather use

    if ((bytes_wrote = write(fd, &x, sizeof(int))) != sizeof(int))
    G_warning("%s", strerror(errno));

    return (bytes_wrote == sizeof(int));

just to be on the safe side


More information about the grass-dev mailing list