Skip to content

Commit eea0d74

Browse files
Dyre TjeldvollDyre Tjeldvoll
authored andcommitted
Bug#11746599: ANALYZE SERVER CODE FOR INCORRECT USAGE OF OFF_T TYPE [noclose]
Step 4, remove HAVE_SEEKO and associated cmake test, and replace with _WIN32, and use _xi64() functions on windows since long is 32 bit there (on Win32 and Win64 alike) Change-Id: If1ef78e57306a0bd8104b341e18d56382c1cbcfe
1 parent e2fbd27 commit eea0d74

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

cmake/os/WindowsCache.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ SET(HAVE_FCNTL CACHE INTERNAL "")
9191
SET(HAVE_FDATASYNC CACHE INTERNAL "")
9292
SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
9393
SET(HAVE_FEDISABLEEXCEPT CACHE INTERNAL "")
94-
SET(HAVE_FSEEKO CACHE INTERNAL "")
9594
SET(HAVE_FSYNC CACHE INTERNAL "")
9695
SET(HAVE_GETHRTIME CACHE INTERNAL "")
9796
# Check needed HAVE_GETNAMEINFO

config.h.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
#cmakedefine HAVE_FDATASYNC 1
9191
#cmakedefine HAVE_DECL_FDATASYNC 1
9292
#cmakedefine HAVE_FEDISABLEEXCEPT 1
93-
#cmakedefine HAVE_FSEEKO 1
9493
#cmakedefine HAVE_FSYNC 1
9594
#cmakedefine HAVE_GETHRTIME 1
9695
#cmakedefine HAVE_GETNAMEINFO 1

configure.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ CHECK_FUNCTION_EXISTS (fcntl HAVE_FCNTL)
262262
CHECK_FUNCTION_EXISTS (fdatasync HAVE_FDATASYNC)
263263
CHECK_SYMBOL_EXISTS(fdatasync "unistd.h" HAVE_DECL_FDATASYNC)
264264
CHECK_FUNCTION_EXISTS (fedisableexcept HAVE_FEDISABLEEXCEPT)
265-
CHECK_FUNCTION_EXISTS (fseeko HAVE_FSEEKO)
266265
CHECK_FUNCTION_EXISTS (fsync HAVE_FSYNC)
267266
CHECK_FUNCTION_EXISTS (gethrtime HAVE_GETHRTIME)
268267
CHECK_FUNCTION_EXISTS (getnameinfo HAVE_GETNAMEINFO)

mysys/my_fstream.cc

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,25 @@
3838
#include "my_dbug.h"
3939
#include "my_inttypes.h"
4040
#include "my_sys.h"
41-
#include "my_thread_local.h"
41+
#include "my_thread_local.h" // set_my_errno
4242
#include "mysys_err.h"
43-
#include "template_utils.h"
43+
#include "template_utils.h" // pointer_cast
4444
#if defined(_WIN32)
45-
#include "mysys/mysys_priv.h"
45+
#include "mysys/mysys_priv.h" // my_win_x
4646
#endif
4747

48-
#ifdef HAVE_FSEEKO
49-
#undef ftell
50-
#undef fseek
51-
#define ftell(A) ftello(A)
52-
#define fseek(A, B, C) fseeko((A), (B), (C))
53-
#endif
48+
namespace {
49+
/**
50+
Portable fseek() wrapper (without the modified semantics of my_fseek()).
51+
*/
52+
int64_t fseek_(FILE *stream, int64_t offset, int whence) {
53+
#ifdef _WIN32
54+
return _fseeki64(stream, offset, whence);
55+
#else
56+
return fseeko(stream, offset, whence);
57+
#endif /* _WIN32 */
58+
}
59+
} // namespace
5460

5561
/**
5662
Read a chunk of bytes from a FILE stream.
@@ -104,7 +110,7 @@ size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags) {
104110
DBUG_TRACE;
105111
DBUG_EXECUTE_IF("simulate_fwrite_error", return -1;);
106112

107-
seekptr = ftell(stream);
113+
seekptr = my_ftell(stream);
108114
for (;;) {
109115
errno = 0;
110116
size_t written =
@@ -119,7 +125,7 @@ size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags) {
119125
Count -= written;
120126

121127
if (errno == EINTR) {
122-
fseek(stream, seekptr, MY_SEEK_SET);
128+
fseek_(stream, seekptr, MY_SEEK_SET);
123129
continue;
124130
}
125131
if (ferror(stream) || (MyFlags & (MY_NABP | MY_FNABP))) {
@@ -155,7 +161,8 @@ size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags) {
155161
*/
156162
my_off_t my_fseek(FILE *stream, my_off_t pos, int whence) {
157163
DBUG_TRACE;
158-
return fseek(stream, pos, whence) ? MY_FILEPOS_ERROR : ftell(stream);
164+
165+
return fseek_(stream, pos, whence) ? MY_FILEPOS_ERROR : my_ftell(stream);
159166
}
160167

161168
/**
@@ -164,7 +171,12 @@ my_off_t my_fseek(FILE *stream, my_off_t pos, int whence) {
164171
my_off_t my_ftell(FILE *stream) {
165172
int64_t pos;
166173
DBUG_TRACE;
167-
pos = ftell(stream);
174+
175+
#ifdef _WIN32
176+
pos = _ftelli64(stream);
177+
#else
178+
pos = ftello(stream);
179+
#endif /* _WIN32 */
168180
return pos;
169181
}
170182

0 commit comments

Comments
 (0)