Fix harmless compiler warnings. Refactor some identifier names for

clearer presentation.

FossilOrigin-Name: 7e3941502789c5afaf19b08112f464abf5e3cba7f92fc9290af2a0f96127ad9a
This commit is contained in:
drh 2023-12-02 18:17:38 +00:00
parent a11aaff05a
commit 53c2160db0
3 changed files with 71 additions and 67 deletions

View File

@ -1,5 +1,5 @@
C Take\sextra\scare\sto\sensure\sthat\sJSONB\svalues\sthat\sare\sin\scache\sare\sactually\nowned\sby\sthe\sJSON\ssubsystem,\sand\sthat\sownership\sof\ssuch\svalues\sis\snot\shanded\nback\sto\sthe\sbytecode\sengine.
D 2023-12-02T18:04:27.395
C Fix\sharmless\scompiler\swarnings.\s\sRefactor\ssome\sidentifier\snames\sfor\nclearer\spresentation.
D 2023-12-02T18:17:38.516
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -688,7 +688,7 @@ F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
F src/hwtime.h f9c2dfb84dce7acf95ce6d289e46f5f9d3d1afd328e53da8f8e9008e3b3caae6
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 3f0a94082d978bbdd33c38fefea15346c6c6bffb70bc645a71dc0f1f87dd3276
F src/json.c 4c6b5c0c731fe7a2b2d28467af747c4744370bd47b5f9d6b7531efb8617eda37
F src/json.c b67328611c8ebc5aca49e2d73b1bad9962948aa5c952f3d96c44eb74ee3d0010
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c 7432c944ff197046d67a1207790a1b13eec4548c85a9457eb0896bb3641dfb36
F src/main.c 1b89f3de98d1b59fec5bac1d66d6ece21f703821b8eaa0d53d9604c35309f6f9
@ -2145,8 +2145,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 26144d1c25ae0435db568009ba05e485d23d146f2b1f29f3a426c87860316aed
R 4e2a070d847085a145ada5a2fea29659
P 1304534001e9ef66c6b12752b69d790bfa3427cc803f87cc48ca22ae12df0fdf
R 1b492fad564bbccdff370d30a804d641
U drh
Z 2cced16db85959c5b0bfa29c3e3e2f71
Z f1274565e5b6e1f5da018a4ab14dfe40
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
1304534001e9ef66c6b12752b69d790bfa3427cc803f87cc48ca22ae12df0fdf
7e3941502789c5afaf19b08112f464abf5e3cba7f92fc9290af2a0f96127ad9a

View File

@ -287,7 +287,7 @@ struct JsonParse {
u8 bReadOnly; /* Do not modify. */
u32 nJPRef; /* Number of references to this object */
u32 iErr; /* Error location in zJson[] */
/* Search and edit information. See jsonLookupBlobStep() */
/* Search and edit information. See jsonLookupStep() */
u8 eEdit; /* Edit operation to apply */
int delta; /* Size change due to the edit */
u32 nIns; /* Number of bytes to insert */
@ -2119,20 +2119,24 @@ static void jsonBlobEdit(
}
/*
** Error returns from jsonLookupBlobStep()
** Error returns from jsonLookupStep()
*/
#define JSON_BLOB_ERROR 0xffffffff
#define JSON_BLOB_NOTFOUND 0xfffffffe
#define JSON_BLOB_PATHERROR 0xfffffffd
#define JSON_BLOB_ISERROR(x) ((x)>=JSON_BLOB_PATHERROR)
#define JSON_LOOKUP_ERROR 0xffffffff
#define JSON_LOOKUP_NOTFOUND 0xfffffffe
#define JSON_LOOKUP_PATHERROR 0xfffffffd
#define JSON_LOOKUP_ISERROR(x) ((x)>=JSON_LOOKUP_PATHERROR)
/*
** Search along zPath to find the Json element specified. Return an
** index into pParse->aBlob[] for the start of that element's value.
**
** Return JSON_BLOB_NOTFOUND if no such element exists.
** If the value found by this routine is the value half of label/value pair
** within an object, then set pPath->iLabel to the start of the corresponding
** label, before returning.
**
** Return one of the JSON_LOOKUP error codes if problems are seen.
*/
static u32 jsonLookupBlobStep(
static u32 jsonLookupStep(
JsonParse *pParse, /* The JSON to search */
u32 iRoot, /* Begin the search at this element of aBlob[] */
const char *zPath, /* The path to search */
@ -2173,7 +2177,7 @@ static u32 jsonLookupBlobStep(
if( zPath[i] ){
i++;
}else{
return JSON_BLOB_PATHERROR;
return JSON_LOOKUP_PATHERROR;
}
testcase( nKey==0 );
}else{
@ -2181,37 +2185,37 @@ static u32 jsonLookupBlobStep(
for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){}
nKey = i;
if( nKey==0 ){
return JSON_BLOB_PATHERROR;
return JSON_LOOKUP_PATHERROR;
}
}
if( (x & 0x0f)!=JSONB_OBJECT ) return JSON_BLOB_NOTFOUND;
if( (x & 0x0f)!=JSONB_OBJECT ) return JSON_LOOKUP_NOTFOUND;
n = jsonbPayloadSize(pParse, iRoot, &sz);
j = iRoot + n; /* j is the index of a label */
iEnd = j+sz;
while( j<iEnd ){
x = pParse->aBlob[j] & 0x0f;
if( x<JSONB_TEXT || x>JSONB_TEXTRAW ) return JSON_BLOB_ERROR;
if( x<JSONB_TEXT || x>JSONB_TEXTRAW ) return JSON_LOOKUP_ERROR;
n = jsonbPayloadSize(pParse, j, &sz);
if( n==0 ) return JSON_BLOB_ERROR;
if( n==0 ) return JSON_LOOKUP_ERROR;
k = j+n; /* k is the index of the label text */
if( k+sz>=iEnd ) return JSON_BLOB_ERROR;
if( k+sz>=iEnd ) return JSON_LOOKUP_ERROR;
if( sz==nKey && memcmp(&pParse->aBlob[k], zKey, nKey)==0 ){
u32 v = k+sz; /* v is the index of the value */
if( ((pParse->aBlob[v])&0x0f)>JSONB_OBJECT ) return JSON_BLOB_ERROR;
if( ((pParse->aBlob[v])&0x0f)>JSONB_OBJECT ) return JSON_LOOKUP_ERROR;
n = jsonbPayloadSize(pParse, v, &sz);
if( n==0 || v+n+sz>iEnd ) return JSON_BLOB_ERROR;
if( n==0 || v+n+sz>iEnd ) return JSON_LOOKUP_ERROR;
assert( j>0 );
rc = jsonLookupBlobStep(pParse, v, &zPath[i], j);
rc = jsonLookupStep(pParse, v, &zPath[i], j);
if( pParse->delta ) jsonAfterEditSizeAdjust(pParse, iRoot);
return rc;
}
j = k+sz;
if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_BLOB_ERROR;
if( ((pParse->aBlob[j])&0x0f)>JSONB_OBJECT ) return JSON_LOOKUP_ERROR;
n = jsonbPayloadSize(pParse, j, &sz);
if( n==0 ) return JSON_BLOB_ERROR;
if( n==0 ) return JSON_LOOKUP_ERROR;
j += n+sz;
}
if( j>iEnd ) return JSON_BLOB_ERROR;
if( j>iEnd ) return JSON_LOOKUP_ERROR;
if( pParse->eEdit>=JEDIT_INS ){
u32 nIns; /* Total bytes to insert (label+value) */
JsonParse v; /* BLOB encoding of the value to be inserted */
@ -2230,8 +2234,8 @@ static u32 jsonLookupBlobStep(
v.eEdit = pParse->eEdit;
v.nIns = pParse->nIns;
v.aIns = pParse->aIns;
rc = jsonLookupBlobStep(&v, 0, &zPath[i], 0);
if( JSON_BLOB_ISERROR(rc) || v.oom ){
rc = jsonLookupStep(&v, 0, &zPath[i], 0);
if( JSON_LOOKUP_ISERROR(rc) || v.oom ){
pParse->oom |= v.oom;
jsonParseReset(&v);
jsonParseReset(&ix);
@ -2257,7 +2261,7 @@ static u32 jsonLookupBlobStep(
}
}else if( zPath[0]=='[' ){
x = pParse->aBlob[iRoot] & 0x0f;
if( x!=JSONB_ARRAY ) return JSON_BLOB_NOTFOUND;
if( x!=JSONB_ARRAY ) return JSON_LOOKUP_NOTFOUND;
n = jsonbPayloadSize(pParse, iRoot, &sz);
k = 0;
i = 1;
@ -2276,31 +2280,31 @@ static u32 jsonLookupBlobStep(
nn = nn*10 + zPath[i] - '0';
i++;
}while( sqlite3Isdigit(zPath[i]) );
if( nn>k ) return JSON_BLOB_NOTFOUND;
if( nn>k ) return JSON_LOOKUP_NOTFOUND;
k -= nn;
}
if( zPath[i]!=']' ){
return JSON_BLOB_PATHERROR;
return JSON_LOOKUP_PATHERROR;
}
}else{
return JSON_BLOB_PATHERROR;
return JSON_LOOKUP_PATHERROR;
}
}
j = iRoot+n;
iEnd = j+sz;
while( j<iEnd ){
if( k==0 ){
rc = jsonLookupBlobStep(pParse, j, &zPath[i+1], 0);
rc = jsonLookupStep(pParse, j, &zPath[i+1], 0);
if( pParse->delta ) jsonAfterEditSizeAdjust(pParse, iRoot);
return rc;
}
k--;
n = jsonbPayloadSize(pParse, j, &sz);
if( n==0 ) return JSON_BLOB_ERROR;
if( n==0 ) return JSON_LOOKUP_ERROR;
j += n+sz;
}
if( j>iEnd ) return JSON_BLOB_ERROR;
if( k>0 ) return JSON_BLOB_NOTFOUND;
if( j>iEnd ) return JSON_LOOKUP_ERROR;
if( k>0 ) return JSON_LOOKUP_NOTFOUND;
if( pParse->eEdit>=JEDIT_INS ){
JsonParse v;
testcase( pParse->eEdit==JEDIT_INS );
@ -2315,8 +2319,8 @@ static u32 jsonLookupBlobStep(
v.eEdit = pParse->eEdit;
v.nIns = pParse->nIns;
v.aIns = pParse->aIns;
rc = jsonLookupBlobStep(&v, 0, &zPath[i+1], 0);
if( JSON_BLOB_ISERROR(rc) || v.oom ){
rc = jsonLookupStep(&v, 0, &zPath[i+1], 0);
if( JSON_LOOKUP_ISERROR(rc) || v.oom ){
pParse->oom |= v.oom;
jsonParseReset(&v);
return rc;
@ -2330,9 +2334,9 @@ static u32 jsonLookupBlobStep(
return j;
}
}else{
return JSON_BLOB_PATHERROR;
return JSON_LOOKUP_PATHERROR;
}
return JSON_BLOB_NOTFOUND;
return JSON_LOOKUP_NOTFOUND;
}
/*
@ -2670,11 +2674,11 @@ static void jsonInsertIntoBlob(
p->nIns = ax.nBlob;
p->aIns = ax.aBlob;
p->delta = 0;
rc = jsonLookupBlobStep(p, 0, zPath+1, 0);
rc = jsonLookupStep(p, 0, zPath+1, 0);
}
jsonParseReset(&ax);
if( rc==JSON_BLOB_NOTFOUND ) continue;
if( JSON_BLOB_ISERROR(rc) ) goto jsonInsertIntoBlob_patherror;
if( rc==JSON_LOOKUP_NOTFOUND ) continue;
if( JSON_LOOKUP_ISERROR(rc) ) goto jsonInsertIntoBlob_patherror;
}
jsonReturnParse(ctx, p);
jsonParseFree(p);
@ -2682,7 +2686,7 @@ static void jsonInsertIntoBlob(
jsonInsertIntoBlob_patherror:
jsonParseFree(p);
if( rc==JSON_BLOB_ERROR ){
if( rc==JSON_LOOKUP_ERROR ){
sqlite3_result_error(ctx, "malformed JSON", -1);
}else{
jsonBadPathError(ctx, zPath);
@ -3149,11 +3153,11 @@ static void jsonArrayLengthFunc(
jsonParseFree(p);
return;
}
i = jsonLookupBlobStep(p, 0, zPath[0]=='$' ? zPath+1 : "@", 0);
if( JSON_BLOB_ISERROR(i) ){
if( i==JSON_BLOB_NOTFOUND ){
i = jsonLookupStep(p, 0, zPath[0]=='$' ? zPath+1 : "@", 0);
if( JSON_LOOKUP_ISERROR(i) ){
if( i==JSON_LOOKUP_NOTFOUND ){
/* no-op */
}else if( i==JSON_BLOB_PATHERROR ){
}else if( i==JSON_LOOKUP_PATHERROR ){
jsonBadPathError(ctx, zPath);
}else{
sqlite3_result_error(ctx, "malformed JSON", -1);
@ -3230,7 +3234,7 @@ static void jsonExtractFunc(
u32 j;
if( zPath==0 ) goto json_extract_error;
if( zPath[0]=='$' ){
j = jsonLookupBlobStep(p, 0, zPath+1, 0);
j = jsonLookupStep(p, 0, zPath+1, 0);
}else if( (flags & JSON_ABPATH) ){
/* The -> and ->> operators accept abbreviated PATH arguments. This
** is mostly for compatibility with PostgreSQL, but also for
@ -3253,7 +3257,7 @@ static void jsonExtractFunc(
jsonAppendRaw(&jx, zPath, nPath);
}
jsonStringTerminate(&jx);
j = jsonLookupBlobStep(p, 0, jx.zBuf, 0);
j = jsonLookupStep(p, 0, jx.zBuf, 0);
jsonStringReset(&jx);
}else{
jsonBadPathError(ctx, zPath);
@ -3280,14 +3284,14 @@ static void jsonExtractFunc(
jsonAppendSeparator(&jx);
jsonXlateBlobToText(p, j, &jx);
}
}else if( j==JSON_BLOB_NOTFOUND ){
}else if( j==JSON_LOOKUP_NOTFOUND ){
if( argc==2 ){
goto json_extract_error; /* Return NULL if not found */
}else{
jsonAppendSeparator(&jx);
jsonAppendRawNZ(&jx, "null", 4);
}
}else if( j==JSON_BLOB_ERROR ){
}else if( j==JSON_LOOKUP_ERROR ){
sqlite3_result_error(ctx, "malformed JSON", -1);
goto json_extract_error;
}else{
@ -3613,8 +3617,8 @@ static void jsonRemoveFunc(
){
JsonParse *p; /* The parse */
const char *zPath = 0; /* Path of element to be removed */
u32 i; /* Loop counter */
int rc; /* Subroutine return code */
int i; /* Loop counter */
u32 rc; /* Subroutine return code */
if( argc<1 ) return;
p = jsonParseFuncArg(ctx, argv[0], JSON_EDITABLE);
@ -3636,9 +3640,9 @@ static void jsonRemoveFunc(
}
p->eEdit = JEDIT_DEL;
p->delta = 0;
rc = jsonLookupBlobStep(p, 0, zPath+1, 0);
if( rc==JSON_BLOB_NOTFOUND ) continue;
if( JSON_BLOB_ISERROR(rc) ) goto json_remove_patherror;
rc = jsonLookupStep(p, 0, zPath+1, 0);
if( rc==JSON_LOOKUP_NOTFOUND ) continue;
if( JSON_LOOKUP_ISERROR(rc) ) goto json_remove_patherror;
}
jsonReturnParse(ctx, p);
jsonParseFree(p);
@ -3738,11 +3742,11 @@ static void jsonTypeFunc(
jsonBadPathError(ctx, zPath);
goto json_type_done;
}
i = jsonLookupBlobStep(p, 0, zPath+1, 0);
if( JSON_BLOB_ISERROR(i) ){
if( i==JSON_BLOB_NOTFOUND ){
i = jsonLookupStep(p, 0, zPath+1, 0);
if( JSON_LOOKUP_ISERROR(i) ){
if( i==JSON_LOOKUP_NOTFOUND ){
/* no-op */
}else if( i==JSON_BLOB_PATHERROR ){
}else if( i==JSON_LOOKUP_PATHERROR ){
jsonBadPathError(ctx, zPath);
}else{
sqlite3_result_error(ctx, "malformed JSON", -1);
@ -4361,8 +4365,8 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
if( levelChange ){
if( p->nParent>0 ){
JsonParent *pParent = &p->aParent[p->nParent-1];
u32 i = pParent->iValue;
p->eType = p->sParse.aBlob[i] & 0x0f;
u32 iVal = pParent->iValue;
p->eType = p->sParse.aBlob[iVal] & 0x0f;
}else{
p->eType = 0;
}
@ -4628,9 +4632,9 @@ static int jsonEachFilter(
i = p->i = 0;
p->eType = 0;
}else{
i = jsonLookupBlobStep(&p->sParse, 0, zRoot+1, 0);
if( JSON_BLOB_ISERROR(i) ){
if( i==JSON_BLOB_NOTFOUND ){
i = jsonLookupStep(&p->sParse, 0, zRoot+1, 0);
if( JSON_LOOKUP_ISERROR(i) ){
if( i==JSON_LOOKUP_NOTFOUND ){
p->i = 0;
p->eType = 0;
p->iEnd = 0;