Avoid left-shifts of signed integers.

FossilOrigin-Name: 0715ce164333e27671efbec8796f238df98cc287
This commit is contained in:
drh 2016-05-03 00:04:55 +00:00
parent 39f98c52d0
commit 48cd59a57d
4 changed files with 20 additions and 21 deletions

View File

@ -278,19 +278,18 @@ static int sessionVarintGet(u8 *aBuf, int *piVal){
return getVarint32(aBuf, *piVal);
}
/* Load an unaligned and unsigned 32-bit integer */
#define SESSION_UINT32(x) (((u32)(x)[0]<<24)|((x)[1]<<16)|((x)[2]<<8)|(x)[3])
/*
** Read a 64-bit big-endian integer value from buffer aRec[]. Return
** the value read.
*/
static sqlite3_int64 sessionGetI64(u8 *aRec){
return (((sqlite3_int64)aRec[0]) << 56)
+ (((sqlite3_int64)aRec[1]) << 48)
+ (((sqlite3_int64)aRec[2]) << 40)
+ (((sqlite3_int64)aRec[3]) << 32)
+ (((sqlite3_int64)aRec[4]) << 24)
+ (((sqlite3_int64)aRec[5]) << 16)
+ (((sqlite3_int64)aRec[6]) << 8)
+ (((sqlite3_int64)aRec[7]) << 0);
u64 x = SESSION_UINT32(aRec);
u32 y = SESSION_UINT32(aRec+4);
x = (x<<32) + y;
return (sqlite3_int64)x;
}
/*

View File

@ -1,5 +1,5 @@
C Remove\ssome\srandomness\sfrom\stest\sscript\stemptable2.test.
D 2016-05-02T19:05:05.108
C Avoid\sleft-shifts\sof\ssigned\sintegers.
D 2016-05-03T00:04:55.196
F Makefile.in 9e816d0323e418fbc0f8b2c05fc14e0b3763d9e8
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 71b8b16cf9393f68e2e2035486ca104872558836
@ -293,7 +293,7 @@ F ext/session/sessionG.test 01ef705096a9d3984eebdcca79807a211dee1b60
F ext/session/session_common.tcl a1293167d14774b5e728836720497f40fe4ea596
F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7
F ext/session/sessionfault2.test 04aa0bc9aa70ea43d8de82c4f648db4de1e990b0
F ext/session/sqlite3session.c beb43b6b888801bb006320bc236baa95f4cc32ae
F ext/session/sqlite3session.c 37485891b4add26cf61495df193c419f36556a32
F ext/session/sqlite3session.h 64e9e7f185725ef43b97f4a9a0c0df0669844f1d
F ext/session/test_session.c 464f2c8bf502795d95969387eb8e93f68c513c15
F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220
@ -387,7 +387,7 @@ F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247
F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba
F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9
F src/tclsqlite.c 9c4c4589d078de37813ded708d8838b338ffb060
F src/test1.c ee8fd5c32acb93fb6fe885ca4801cfab85f5563f
F src/test1.c c0e5b69f99e95a2c9f55fdb6e46b44f1a15292d8
F src/test2.c 5586f43fcd9a1be0830793cf9d354082c261b25b
F src/test3.c 0df6f8dbb4cbaa7106397c70a271fa6a43659042
F src/test4.c d168f83cc78d02e8d35567bb5630e40dcd85ac1e
@ -1486,7 +1486,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 088cf83872f6477c3b297c58d6f8a5def7025daf
R 237f2aea599511d792221ce999e030ab
U dan
Z f86754e59f932bdb68bb3e5db8c95fe0
P 5830cf72e9e870830d088399f1ccb03ed6522582
R 350580348db69c537adc1a64222fc40a
U drh
Z 10c9aec7cf14a46e7039005f7f038452

View File

@ -1 +1 @@
5830cf72e9e870830d088399f1ccb03ed6522582
0715ce164333e27671efbec8796f238df98cc287

View File

@ -6700,8 +6700,8 @@ static int sorter_test_sort4_helper(
const char *zSql2;
int nStep;
int iStep;
int iCksum1 = 0;
int iCksum2 = 0;
unsigned int iCksum1 = 0;
unsigned int iCksum2 = 0;
int rc;
int iB;
sqlite3 *db;
@ -6728,7 +6728,7 @@ static int sorter_test_sort4_helper(
return TCL_ERROR;
}
iCksum1 += (iCksum1 << 3) + a;
iCksum1 += (iCksum1 << 3) + (unsigned int)a;
}
rc = sqlite3_finalize(pStmt);
if( rc!=SQLITE_OK ) goto sql_error;
@ -6737,7 +6737,7 @@ static int sorter_test_sort4_helper(
if( rc!=SQLITE_OK ) goto sql_error;
for(iStep=0; SQLITE_ROW==sqlite3_step(pStmt); iStep++){
int a = sqlite3_column_int(pStmt, 0);
iCksum2 += (iCksum2 << 3) + a;
iCksum2 += (iCksum2 << 3) + (unsigned int)a;
}
rc = sqlite3_finalize(pStmt);
if( rc!=SQLITE_OK ) goto sql_error;