SQLite

Check-in [da06168c]
Login

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

Overview
Comment:Fix problems with handling return value of mmap() in lsm_unix.c (mmap() returns MAP_FAILED on error, not NULL).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: da06168c09df5c0e8e10d0f9618e69217d4c0173a8199660bad2805f009d7b08
User & Date: dan 2020-06-22 16:02:06
Context
2020-06-23
17:57
Try to remove end-of-line whitespace when building the amalgamation. (check-in: be3e7814 user: drh tags: trunk)
2020-06-22
16:02
Fix problems with handling return value of mmap() in lsm_unix.c (mmap() returns MAP_FAILED on error, not NULL). (check-in: da06168c user: dan tags: trunk)
2020-06-20
03:43
Work around a bug (an incorrect warning) in Clang-8. (check-in: 06729114 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ext/lsm1/lsm_unix.c.
224
225
226
227
228
229
230




231
232
233
234
235
236
237
    if( iSz<iMin ){
      iSz = ((iMin + nIncrSz-1) / nIncrSz) * nIncrSz;
      prc = ftruncate(p->fd, iSz);
      if( prc!=0 ) return LSM_IOERR_BKPT;
    }

    p->pMap = mmap(0, iSz, PROT_READ|PROT_WRITE, MAP_SHARED, p->fd, 0);




    p->nMap = iSz;
  }

  *ppOut = p->pMap;
  *pnOut = p->nMap;
  return LSM_OK;
}







>
>
>
>







224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
    if( iSz<iMin ){
      iSz = ((iMin + nIncrSz-1) / nIncrSz) * nIncrSz;
      prc = ftruncate(p->fd, iSz);
      if( prc!=0 ) return LSM_IOERR_BKPT;
    }

    p->pMap = mmap(0, iSz, PROT_READ|PROT_WRITE, MAP_SHARED, p->fd, 0);
    if( p->pMap==MAP_FAILED ){
      p->pMap = 0;
      return LSM_IOERR_BKPT;
    }
    p->nMap = iSz;
  }

  *ppOut = p->pMap;
  *pnOut = p->nMap;
  return LSM_OK;
}
409
410
411
412
413
414
415
416



417
418
419
420
421
422
423
    p->nShm = nNew;
  }

  if( p->apShm[iChunk]==0 ){
    p->apShm[iChunk] = mmap(0, LSM_SHM_CHUNK_SIZE, 
        PROT_READ|PROT_WRITE, MAP_SHARED, p->shmfd, iChunk*LSM_SHM_CHUNK_SIZE
    );
    if( p->apShm[iChunk]==0 ) return LSM_IOERR_BKPT;



  }

  *ppShm = p->apShm[iChunk];
  return LSM_OK;
}

static void lsmPosixOsShmBarrier(void){







|
>
>
>







413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
    p->nShm = nNew;
  }

  if( p->apShm[iChunk]==0 ){
    p->apShm[iChunk] = mmap(0, LSM_SHM_CHUNK_SIZE, 
        PROT_READ|PROT_WRITE, MAP_SHARED, p->shmfd, iChunk*LSM_SHM_CHUNK_SIZE
    );
    if( p->apShm[iChunk]==MAP_FAILED ){
      p->apShm[iChunk] = 0;
      return LSM_IOERR_BKPT;
    }
  }

  *ppShm = p->apShm[iChunk];
  return LSM_OK;
}

static void lsmPosixOsShmBarrier(void){