/ Check-in [2822cbb9]
Login

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

Overview
Comment:Fully initialize the unused bytes of the buffer that will become the journal file header, in order to silence a complaint from valgrind. (CVS 5968)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2822cbb960dbef9d30586ee112d74f9f566309fa
User & Date: drh 2008-11-29 22:49:23
Context
2008-12-03
19:34
Continue with the cleanup of os_unix.c. (CVS 5969) check-in: 215d36ea user: drh tags: trunk
2008-11-29
22:49
Fully initialize the unused bytes of the buffer that will become the journal file header, in order to silence a complaint from valgrind. (CVS 5968) check-in: 2822cbb9 user: drh tags: trunk
02:20
Continuing to refactor os_unix.c. This is an incremental check-in. (CVS 5967) check-in: c13df031 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.c.

    14     14   ** The pager is used to access a database disk file.  It implements
    15     15   ** atomic commit and rollback through the use of a journal file that
    16     16   ** is separate from the database file.  The pager also implements file
    17     17   ** locking to prevent two processes from writing the same database
    18     18   ** file simultaneously, or one process from reading the database while
    19     19   ** another is writing.
    20     20   **
    21         -** @(#) $Id: pager.c,v 1.509 2008/11/26 07:25:52 danielk1977 Exp $
           21  +** @(#) $Id: pager.c,v 1.510 2008/11/29 22:49:23 drh Exp $
    22     22   */
    23     23   #ifndef SQLITE_OMIT_DISKIO
    24     24   #include "sqliteInt.h"
    25     25   
    26     26   /*
    27     27   ** Macros for troubleshooting.  Normally turned off
    28     28   */
................................................................................
   677    677     /* The random check-hash initialiser */ 
   678    678     sqlite3_randomness(sizeof(pPager->cksumInit), &pPager->cksumInit);
   679    679     put32bits(&zHeader[sizeof(aJournalMagic)+4], pPager->cksumInit);
   680    680     /* The initial database size */
   681    681     put32bits(&zHeader[sizeof(aJournalMagic)+8], pPager->dbSize);
   682    682     /* The assumed sector size for this process */
   683    683     put32bits(&zHeader[sizeof(aJournalMagic)+12], pPager->sectorSize);
          684  +
          685  +  /* Initializing the tail of the buffer is not necessary.  Everything
          686  +  ** works find if the following memset() is omitted.  But initializing
          687  +  ** the memory prevents valgrind from complaining, so we are willing to
          688  +  ** take the performance hit.
          689  +  */
          690  +  memset(&zHeader[sizeof(aJournalMagic)+16], 0,
          691  +         nHeader-(sizeof(aJournalMagic)+16));
          692  +
   684    693     if( pPager->journalHdr==0 ){
   685    694       /* The page size */
   686    695       put32bits(&zHeader[sizeof(aJournalMagic)+16], pPager->pageSize);
   687    696     }
   688    697   
   689    698     for(nWrite=0; rc==SQLITE_OK&&nWrite<JOURNAL_HDR_SZ(pPager); nWrite+=nHeader){
   690    699       IOTRACE(("JHDR %p %lld %d\n", pPager, pPager->journalHdr, nHeader))