Ticket #2989 (closed defect: wontfix)
Fix code which depends on signed overflow in C (which isn't defined in C)
Reported by: | vda | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | mc-vfs | Version: | master |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | no branch | Votes for changeset: |
Description
The warnings are:
src/vfs/smbfs/helpers/lib/time.c:177:16: warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false [-Wstrict-overflow]
src/vfs/smbfs/helpers/lib/time.c:181:16: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Wstrict-overflow]
and they seems to be valid, and gcc people do intend to make gcc play tricks under "signed overflow is undefined, so we can assume it never happens" banner.
The patch was sent by email with subject line
"Fix code which depends on signed overflow in C (which isn't defined in C)".
For your easy reference, it is just:
/* no entry will cover more than 6 months */ - low = t - MAX_DST_WIDTH / 2; - if (t < low) + if (t > TIME_T_MIN + MAX_DST_WIDTH / 2) + low = t - MAX_DST_WIDTH / 2; + else low = TIME_T_MIN; - high = t + MAX_DST_WIDTH / 2; - if (high < t) + if (t < TIME_T_MAX - MAX_DST_WIDTH / 2) + high = t + MAX_DST_WIDTH / 2; + else high = TIME_T_MAX;