diff --git a/modules/src/object/rd_bytes.c b/modules/src/object/rd_bytes.c index e46f4cb43..3c9822ffb 100644 --- a/modules/src/object/rd_bytes.c +++ b/modules/src/object/rd_bytes.c @@ -1,5 +1,10 @@ #define MININT (1 << (sizeof(int) * 8 - 1)) -#define MAXCHUNK (-(MININT + 1)) /* Highest count we write(2). */ +#define MAXCHUNK (~MININT) /* Highest count we read(2). */ +/* Unfortunately, MAXCHUNK is too large with some compilers. Put it in + an int! +*/ + +int maxchunk = MAXCHUNK; /* * We don't have to worry about byte order here. @@ -12,7 +17,7 @@ rd_bytes(fd, string, cnt) { while (cnt) { - register int n = cnt >= MAXCHUNK ? MAXCHUNK : cnt; + register int n = cnt >= maxchunk ? maxchunk : cnt; if (read(fd, string, n) != n) rd_fatal(); diff --git a/modules/src/object/wr_bytes.c b/modules/src/object/wr_bytes.c index 8dccc4b16..55e8932e2 100644 --- a/modules/src/object/wr_bytes.c +++ b/modules/src/object/wr_bytes.c @@ -1,5 +1,10 @@ #define MININT (1 << (sizeof(int) * 8 - 1)) -#define MAXCHUNK (-(MININT + 1)) /* Highest count we write(2). */ +#define MAXCHUNK (~MININT) /* Highest count we write(2). */ +/* Notice that MAXCHUNK itself might be too large with some compilers. + You have to put it in an int! +*/ + +int maxchunk = MAXCHUNK; /* * Just write "cnt" bytes to file-descriptor "fd". @@ -10,7 +15,7 @@ wr_bytes(fd, string, cnt) { while (cnt) { - register int n = cnt >= MAXCHUNK ? MAXCHUNK : cnt; + register int n = cnt >= maxchunk ? maxchunk : cnt; if (write(fd, string, n) != n) wr_fatal();