From df1a56253f6f3d000d89262e70934481dadca808 Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Fri, 21 May 2010 21:09:51 +0300 Subject: [PATCH] Use the correct len instead of sizeof(void) in posix_fadvise() Also explain in the comment the units of the "offset" parameter --- storage/innobase/row/row0merge.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/storage/innobase/row/row0merge.c b/storage/innobase/row/row0merge.c index 0e03ea3e178..d9084bb4ffd 100644 --- a/storage/innobase/row/row0merge.c +++ b/storage/innobase/row/row0merge.c @@ -696,7 +696,9 @@ ibool row_merge_read( /*===========*/ int fd, /*!< in: file descriptor */ - ulint offset, /*!< in: offset where to read */ + ulint offset, /*!< in: offset where to read + in number of row_merge_block_t + elements */ row_merge_block_t* buf) /*!< out: data */ { ib_uint64_t ofs = ((ib_uint64_t) offset) * sizeof *buf; @@ -735,17 +737,18 @@ ibool row_merge_write( /*============*/ int fd, /*!< in: file descriptor */ - ulint offset, /*!< in: offset where to write */ + ulint offset, /*!< in: offset where to write, + in number of row_merge_block_t elements */ const void* buf) /*!< in: data */ { - ib_uint64_t ofs = ((ib_uint64_t) offset) - * sizeof(row_merge_block_t); + size_t buf_len = sizeof(row_merge_block_t); + ib_uint64_t ofs = buf_len * (ib_uint64_t) offset; ibool ret; ret = os_file_write("(merge)", OS_FILE_FROM_FD(fd), buf, (ulint) (ofs & 0xFFFFFFFF), (ulint) (ofs >> 32), - sizeof(row_merge_block_t)); + buf_len); #ifdef UNIV_DEBUG if (row_merge_print_block_write) { @@ -757,7 +760,7 @@ row_merge_write( #ifdef POSIX_FADV_DONTNEED /* The block will be needed on the next merge pass, but it can be evicted from the file cache meanwhile. */ - posix_fadvise(fd, ofs, sizeof *buf, POSIX_FADV_DONTNEED); + posix_fadvise(fd, ofs, buf_len, POSIX_FADV_DONTNEED); #endif /* POSIX_FADV_DONTNEED */ return(UNIV_LIKELY(ret));