On 28/05/11 22:47, Jim Meyering wrote: > Jim Meyering wrote: > >> These (off_t) casts are anachronistic. >> They were useful in pre-ANSI-C days, i.e., before prototypes. >> There are two remaining off_t casts, and neither appears useful: >> (one is even inconsistently formatted, with no space after the ")" ;-) >> >> src/shred.c: if (offset > OFF_T_MAX - (off_t) soff) >> src/truncate.c: if (ssize > OFF_T_MAX - (off_t)fsize) >> >> So I'll probably remove them, too. > > Now I'm not so sure. > soff is of type size_t and fsize is uintmax_t, > each of which may be wider than off_t. > I suspect that each of these trigger one of the warnings > that we have not enabled.
Yes it will trigger -Wsign-compare which has helped me find hard to spot bugs. It will also cause a bug I think when ssize is negative, as then it will be promoted to a large positive number for the comparison. The truncate-overflow test catches this change in behavior. cheers, Pádraig.
