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

Peng Haitao
2011-01-19T09:08:55Z

Hi Garrett,

Garrett Cooper said the following on 2011-1-19 16:47:
>
> How about the following item?
> Please try the attached patch over the following -- it's just
> there for review.

The patch is OK, thanks:)

--
Best Regards,
Peng Haitao

> Thanks,
> -Garrett
>
> $ git diff testcases/kernel/syscalls/fsync/fsync02.c
> diff --git a/testcases/kernel/syscalls/fsync/fsync02.c
> b/testcases/kernel/syscalls/fsync/fsync02.c
> index 213eac3..6227a84 100644
> --- a/testcases/kernel/syscalls/fsync/fsync02.c
> +++ b/testcases/kernel/syscalls/fsync/fsync02.c
> @@ -102,7 +102,8 @@ int main(int ac, char **av)
> }
>
> for (i = 1; i <= data_blocks; i++) {
> - offset = (i * BLOCKSIZE * max_block) /
> data_blocks - BUFSIZ;
> + offset = i * ((BLOCKSIZE * max_block) / data_blocks);
> + offset -= 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 +198,4 @@ void cleanup()
>
> tst_rmdir();
>
> -}
> \ No newline at end of file
> +}