| Summary: | incorrect off_t value range / causing lseek failure? | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Jin Guojun <jin> |
| Component: | i386 | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | Unspecified | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed You can't write off_t lret = 5 + (1<<33); You must write off_t lret = 5 + ((off_t)1<<33); If you change your sample program appropriately, it appears to work as expected. My interpretation of this is that the reason lseek() did not work for you is due to the incorrect lack of a necessary cast somewhere. Responsible Changed From-To: gnats-admin->freebsd-bugs Misfiled PR. |
op2.lbl.gov: make x cc -O x.c -o x -lm x.c: In function `main': x.c:8: warning: left shift count >= width of type *** Error code 1 Two problems: (1) off_t is an 8 byte type, so it should be able to handle more than 32-bit data. I test this because the lseek() cannot seek beyond the 2GB range. I am not sure if off_t causes this proble, or lseek() is not implemented to do so; the vfs_syscall.c:lseek() seems no problem, but depends on off_t. (2) lseek fails to seek beyond 2GB range; but fseek works OK. (3) There is no correct format for I/O off_t data in 2.2.x releases. Fix: Not clear if this is a GNU CC problem or kernel type-definition issue. How-To-Repeat: /* x.c */ #include <sys/types.h> #include <stdlib.h> #include <limits.h> main ( int c, char **v ) { off_t lret = 5 + (1<<33), bottom = 12345; /* line 8 */ char foo[64]; if (c <= 1) { printf("%s #\n", v[0]); exit(1); } bottom = strtouq(v[1], &foo, 10); printf("lret = %lld, bt = %lld : extra %ld\n", lret, bottom); printf("lret = %ld, bt = %ld : extra %ld\n", lret, bottom); }