Commit 9cc182c2 authored by whesse's avatar whesse Committed by Commit bot

SQLite's recover.c should be valid C code

Move two variable declarations to the top of their function, so
Chromium's version of SQLite compiles on Windows. SQLite is used
by NSS on Dart's standalone Windows executable.

NOTRY=true
This is not based on src/, and is not tested until DEPS are updated.

This patch is not added to recover.patch, because the last 3 patches,
including the one this fixes, are not there, and recover.patch says:
    Since recover.c is in somewhat active development, it is possible that
    the patch below will not reliably re-create the file.

Review URL: https://codereview.chromium.org/552673003

Cr-Commit-Position: refs/heads/master@{#295260}
parent eadba519
...@@ -110889,6 +110889,8 @@ static void interiorCursorDestroy(RecoverInteriorCursor *pCursor){ ...@@ -110889,6 +110889,8 @@ static void interiorCursorDestroy(RecoverInteriorCursor *pCursor){
/* Internal helper. Reset storage in preparation for iterating pPage. */ /* Internal helper. Reset storage in preparation for iterating pPage. */
static void interiorCursorSetPage(RecoverInteriorCursor *pCursor, static void interiorCursorSetPage(RecoverInteriorCursor *pCursor,
DbPage *pPage){ DbPage *pPage){
const unsigned knMinCellLength = 2 + 4 + 1;
unsigned nMaxChildren;
assert( PageHeader(pPage)[kiPageTypeOffset]==kTableInteriorPage ); assert( PageHeader(pPage)[kiPageTypeOffset]==kTableInteriorPage );
if( pCursor->pPage ){ if( pCursor->pPage ){
...@@ -110909,8 +110911,7 @@ static void interiorCursorSetPage(RecoverInteriorCursor *pCursor, ...@@ -110909,8 +110911,7 @@ static void interiorCursorSetPage(RecoverInteriorCursor *pCursor,
* each child contains a 32-bit page number and at least a varint (min size of * each child contains a 32-bit page number and at least a varint (min size of
* one byte). The final child page is in the header. * one byte). The final child page is in the header.
*/ */
const unsigned knMinCellLength = 2 + 4 + 1; nMaxChildren =
unsigned nMaxChildren =
(pCursor->nPageSize - kiPageInteriorHeaderBytes) / knMinCellLength + 1; (pCursor->nPageSize - kiPageInteriorHeaderBytes) / knMinCellLength + 1;
if (pCursor->nChildren > nMaxChildren) { if (pCursor->nChildren > nMaxChildren) {
pCursor->nChildren = nMaxChildren; pCursor->nChildren = nMaxChildren;
...@@ -643,6 +643,8 @@ static void interiorCursorDestroy(RecoverInteriorCursor *pCursor){ ...@@ -643,6 +643,8 @@ static void interiorCursorDestroy(RecoverInteriorCursor *pCursor){
/* Internal helper. Reset storage in preparation for iterating pPage. */ /* Internal helper. Reset storage in preparation for iterating pPage. */
static void interiorCursorSetPage(RecoverInteriorCursor *pCursor, static void interiorCursorSetPage(RecoverInteriorCursor *pCursor,
DbPage *pPage){ DbPage *pPage){
const unsigned knMinCellLength = 2 + 4 + 1;
unsigned nMaxChildren;
assert( PageHeader(pPage)[kiPageTypeOffset]==kTableInteriorPage ); assert( PageHeader(pPage)[kiPageTypeOffset]==kTableInteriorPage );
if( pCursor->pPage ){ if( pCursor->pPage ){
...@@ -669,8 +671,7 @@ static void interiorCursorSetPage(RecoverInteriorCursor *pCursor, ...@@ -669,8 +671,7 @@ static void interiorCursorSetPage(RecoverInteriorCursor *pCursor,
* byte is corrupted. Could be an overflow page, but it would require * byte is corrupted. Could be an overflow page, but it would require
* a very large database. * a very large database.
*/ */
const unsigned knMinCellLength = 2 + 4 + 1; nMaxChildren =
unsigned nMaxChildren =
(pCursor->nPageSize - kiPageInteriorHeaderBytes) / knMinCellLength + 1; (pCursor->nPageSize - kiPageInteriorHeaderBytes) / knMinCellLength + 1;
if (pCursor->nChildren > nMaxChildren) { if (pCursor->nChildren > nMaxChildren) {
pCursor->nChildren = nMaxChildren; pCursor->nChildren = nMaxChildren;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment