/ Check-in [360c0fd1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix several harmless compiler warnings.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | winPreCache
Files: files | file ages | folders
SHA1:360c0fd1cf9db5f1e4f670a4b95971daaeaa5879
User & Date: mistachkin 2014-05-09 00:36:06
Context
2014-05-09
00:36
Fix several harmless compiler warnings. Closed-Leaf check-in: 360c0fd1 user: mistachkin tags: winPreCache
2014-05-08
22:15
Fix typos in logging code. check-in: dc7f84df user: mistachkin tags: winPreCache
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_win.c.

3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277

3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
  DWORD dwAmt;
  DWORD nRead;

  if( !osDuplicateHandle(GetCurrentProcess(), pFile->h, GetCurrentProcess(),
                         &dupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS) ){
    pFile->lastErrno = osGetLastError();
    OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR\n", dupHandle));
    return winLogError(SQLITE_IOERR, pFile->lastErrno,
                       "winPreCacheThread1", pFile->zPath);
  }
  dwSize = osSetFilePointer(dupHandle, 0, 0, FILE_END);
  if( (dwSize==INVALID_SET_FILE_POINTER
      && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
    pFile->lastErrno = lastErrno;
    osCloseHandle(dupHandle);
    OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SEEK\n", dupHandle));
    return winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
                       "winPreCacheThread2", pFile->zPath);
  }
  dwRet = osSetFilePointer(dupHandle, 0, 0, FILE_BEGIN);
  if( (dwRet==INVALID_SET_FILE_POINTER
      && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
    pFile->lastErrno = lastErrno;
    osCloseHandle(dupHandle);
    OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SEEK\n", dupHandle));
    return winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
                       "winPreCacheThread3", pFile->zPath);
  }
  dwAmt = 4194304; /* TODO: Tuning. */
  if( dwSize<dwAmt ){
    dwAmt = dwSize;
  }
  pBuf = sqlite3MallocZero( dwAmt );
  if( pBuf==0 ){
    osCloseHandle(dupHandle);
    OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_NOMEM\n", dupHandle));
    return SQLITE_IOERR_NOMEM;
  }
  while( 1 ){
    if( !osReadFile(dupHandle, pBuf, dwAmt, &nRead, 0) ){
      pFile->lastErrno = osGetLastError();
      sqlite3_free(pBuf);
      osCloseHandle(dupHandle);
      OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_READ\n", dupHandle));
      return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
                         "winPreCacheThread4", pFile->zPath);
    }
    if( nRead<dwAmt ){
      sqlite3_free(pBuf);
      osCloseHandle(dupHandle);
      OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SHORT_READ\n", dupHandle));
      return winLogError(SQLITE_IOERR_SHORT_READ, pFile->lastErrno,

                         "winPreCacheThread5", pFile->zPath);
    }
    dwSize -= dwAmt;
    if( dwSize==0 ){
      break;
    }
  }
  sqlite3_free(pBuf);
  osCloseHandle(dupHandle);
  return SQLITE_OK;
}
#endif

/* 
** Windows will only let you create file view mappings
** on allocation size granularity boundaries.
** During sqlite3_os_init() we do a GetSystemInfo()







|
|







|
|







|
|









|







|
|





|
>
|








|







3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
  DWORD dwAmt;
  DWORD nRead;

  if( !osDuplicateHandle(GetCurrentProcess(), pFile->h, GetCurrentProcess(),
                         &dupHandle, 0, FALSE, DUPLICATE_SAME_ACCESS) ){
    pFile->lastErrno = osGetLastError();
    OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR\n", dupHandle));
    return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR, pFile->lastErrno,
                                         "winPreCacheThread1", pFile->zPath));
  }
  dwSize = osSetFilePointer(dupHandle, 0, 0, FILE_END);
  if( (dwSize==INVALID_SET_FILE_POINTER
      && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
    pFile->lastErrno = lastErrno;
    osCloseHandle(dupHandle);
    OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SEEK\n", dupHandle));
    return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
                                         "winPreCacheThread2", pFile->zPath));
  }
  dwRet = osSetFilePointer(dupHandle, 0, 0, FILE_BEGIN);
  if( (dwRet==INVALID_SET_FILE_POINTER
      && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
    pFile->lastErrno = lastErrno;
    osCloseHandle(dupHandle);
    OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SEEK\n", dupHandle));
    return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
                                         "winPreCacheThread3", pFile->zPath));
  }
  dwAmt = 4194304; /* TODO: Tuning. */
  if( dwSize<dwAmt ){
    dwAmt = dwSize;
  }
  pBuf = sqlite3MallocZero( dwAmt );
  if( pBuf==0 ){
    osCloseHandle(dupHandle);
    OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_NOMEM\n", dupHandle));
    return SQLITE_INT_TO_PTR(SQLITE_IOERR_NOMEM);
  }
  while( 1 ){
    if( !osReadFile(dupHandle, pBuf, dwAmt, &nRead, 0) ){
      pFile->lastErrno = osGetLastError();
      sqlite3_free(pBuf);
      osCloseHandle(dupHandle);
      OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_READ\n", dupHandle));
      return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
                                           "winPreCacheThread4", pFile->zPath));
    }
    if( nRead<dwAmt ){
      sqlite3_free(pBuf);
      osCloseHandle(dupHandle);
      OSTRACE(("PRE-CACHE file=%p, rc=SQLITE_IOERR_SHORT_READ\n", dupHandle));
      return SQLITE_INT_TO_PTR(winLogError(SQLITE_IOERR_SHORT_READ,
                                           pFile->lastErrno,
                                           "winPreCacheThread5", pFile->zPath));
    }
    dwSize -= dwAmt;
    if( dwSize==0 ){
      break;
    }
  }
  sqlite3_free(pBuf);
  osCloseHandle(dupHandle);
  return SQLITE_INT_TO_PTR(SQLITE_OK);
}
#endif

/* 
** Windows will only let you create file view mappings
** on allocation size granularity boundaries.
** During sqlite3_os_init() we do a GetSystemInfo()