xfsprogs: Fix mismatched return type of filesize()
Quoted 8 lines · Pavel Reichl
The function
filesize()was declared with a return type of 'long' but defined with 'off_t'. This mismatch caused build issues due to type incompatibility.This commit updates the declaration to match the definition, ensuring consistency and preventing potential compilation errors.
Fixes 73fb78e5ee8 ("mkfs: support copying in large or sparse files")
I had run into this issue when building xfsprogs on i386, and had investigated the compilation failure before finding this commit in origin/for-next. But in my fix, I also found that there was a missing long -> off_t conversion in setup_proto():
mkfs/proto.c +1 -1
@@ -61,7 +61,7 @@ setup_proto(char *buf =NULL ;static char dflt[] ="d--755 0 0 $" ;int fd; -long size; +off_t size;if (!fname)return dflt;
... since setup_proto() also calls filesize():
if ((fd = open(fname, O_RDONLY)) < 0 || (size = filesize(fd)) < 0) {How important is it fix this up? I can send a formal patch if that would be helpful, but commit a5466cee9874 is certainly enough to fix the build failure so maybe it's enough.
Cheers,
- Ted
Quoted 29 lines · Theodore Ts'o
Quoted 8 lines · Pavel Reichl
The function
filesize()was declared with a return type of 'long' but defined with 'off_t'. This mismatch caused build issues due to type incompatibility.This commit updates the declaration to match the definition, ensuring consistency and preventing potential compilation errors.
Fixes 73fb78e5ee8 ("mkfs: support copying in large or sparse files")I had run into this issue when building xfsprogs on i386, and had investigated the compilation failure before finding this commit in origin/for-next. But in my fix, I also found that there was a missing long ->
off_tconversion insetup_proto():mkfs/proto.c +1
-1@@ -61,7 +61,7 @@ setup_proto(char *buf =NULL ;static char dflt[] ="d--755 0 0 $" ;int fd; -long size; +off_t size;if (!fname)return dflt;
Quoted 7 lines
... since
setup_proto()also callsfilesize():if ((fd = open(fname, O_RDONLY)) < 0 || (size = filesize(fd)) < 0) {How important is it fix this up? I can send a formal patch if that would be helpful, but commit
a5466cee9874is certainly enough to fix the build failure so maybe it's enough.
Every fix is welcome, this is something that can clearly be tripped over in the future.
Quoted 4 lines
Cheers,
- Ted
Quoted 29 lines · Theodore Ts'o
Quoted 8 lines · Pavel Reichl
The function
filesize()was declared with a return type of 'long' but defined with 'off_t'. This mismatch caused build issues due to type incompatibility.This commit updates the declaration to match the definition, ensuring consistency and preventing potential compilation errors.
Fixes 73fb78e5ee8 ("mkfs: support copying in large or sparse files")I had run into this issue when building xfsprogs on i386, and had investigated the compilation failure before finding this commit in origin/for-next. But in my fix, I also found that there was a missing long ->
off_tconversion insetup_proto():mkfs/proto.c +1
-1@@ -61,7 +61,7 @@ setup_proto(char *buf =NULL ;static char dflt[] ="d--755 0 0 $" ;int fd; -long size; +off_t size;if (!fname)return dflt;
Quoted 7 lines
... since
setup_proto()also callsfilesize():if ((fd = open(fname, O_RDONLY)) < 0 || (size = filesize(fd)) < 0) {How important is it fix this up? I can send a formal patch if that would be helpful, but commit
a5466cee9874is certainly enough to fix the build failure so maybe it's enough.
Yes, this is important -- off_t can be larger than long, and that can result in incorrect truncations. I hope that nobody will ever pass mkfs a 5GB protofile on 32-bit, but at least the C type usage could be correct.
--D
Quoted 5 lines
Cheers,
- Ted