[LTP] [PATCH] fsync02: fix error of overflow from MUL

Peng Haitao
2011-01-19T08:19:31Z

Hi Garrett,

If the third argument is SEEK_SET of function fsync(), offset can not be
negative. But when overflow from MUL, the offset is negative.

Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>

---
testcases/kernel/syscalls/fsync/fsync02.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/fsync/fsync02.c b/testcases/kernel/syscalls/fsync/fsync02.c
index 213eac3..64bb012 100644
--- a/testcases/kernel/syscalls/fsync/fsync02.c
+++ b/testcases/kernel/syscalls/fsync/fsync02.c
@@ -102,7 +102,7 @@ int main(int ac, char **av)
}

for (i = 1; i <= data_blocks; i++) {
- offset = (i * BLOCKSIZE * max_block) / data_blocks - BUFSIZ;
+ offset = (BLOCKSIZE * max_block) / data_blocks * i - BUFSIZ;
if ((offsetret = lseek(fd, offset, SEEK_SET)) != offset)
tst_brkm(TBROK|TERRNO, cleanup, "lseek failed: %ld, %ld", offsetret, offset);
if ((ret = write(fd, pbuf, BUFSIZ)) != BUFSIZ)
@@ -197,4 +197,4 @@ void cleanup()

tst_rmdir();

-}
\ No newline at end of file
+}
--
1.7.3.1

--
Best Regards,
Peng Haitao