From: drh <> Date: Mon, 4 Oct 2021 16:14:51 +0000 (+0000) Subject: Fix harmless static analyzer warnings in auxiliary build tools, mkkeywordhash.c X-Git-Tag: version-3.37.0~166 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1076130a5d844978948247fb89374a91e9edab13;p=thirdparty%2Fsqlite.git Fix harmless static analyzer warnings in auxiliary build tools, mkkeywordhash.c and lemon.c. No changes to the SQLite core. FossilOrigin-Name: f2f279b2cc1c8b3b162058c33956be4037cd519715ac0c4290f10c58d2528f0a --- diff --git a/manifest b/manifest index eea02ea2a0..3cd35b9592 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\sstatic\sanalyzer\swarnings. -D 2021-10-04T15:08:49.115 +C Fix\sharmless\sstatic\sanalyzer\swarnings\sin\sauxiliary\sbuild\stools,\smkkeywordhash.c\nand\slemon.c.\s\sNo\schanges\sto\sthe\sSQLite\score. +D 2021-10-04T16:14:51.752 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -1847,7 +1847,7 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5 F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f -F tool/lemon.c dabeb66806057235fdca34d77e077a554396d8b8c2e1982dfd292b9dba3be13c +F tool/lemon.c 258881835bd5bccd0c74fb110fe54244ff18e8e7ef3d949cbdab7187f02132bb F tool/lempar.c 7d4b1c863a6c7f75f0a04bfa7000b7388898c9ee9c906adc675bc40590ad0abe F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 @@ -1857,7 +1857,7 @@ F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a19 F tool/mkautoconfamal.sh f62353eb6c06ab264da027fd4507d09914433dbdcab9cb011cdc18016f1ab3b8 F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x F tool/mkctimec.tcl 5ef1891ed3d0e8143ff39bad7c01ed60c2817a2fb2d9a09487f7ccad2df621e4 -F tool/mkkeywordhash.c 7b1ffdb0731938cfb52dbf57461ff9132cb350612d944530e2f6031a7f16bf69 +F tool/mkkeywordhash.c 35bfc41adacc4aa6ef6fca7fd0c63e0ec0534b78daf4d0cfdebe398216bbffc3 F tool/mkmsvcmin.tcl 6ecab9fe22c2c8de4d82d4c46797bda3d2deac8e763885f5a38d0c44a895ab33 F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef F tool/mkopcodeh.tcl 130b88697da6ec5b89b41844d955d08fb62c2552e889dec8c7bcecb28d8f50bd @@ -1929,7 +1929,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 886feffaad6baac37dfaab489c2aecc4abf51a3a5bce1e8a94be7cc1d2a3c30c -R 4f79fd109adffef1d1d3caa9f4ec93b1 +P 1ebcde72e2046dffaa408d2a5a4a5bbf35fdf4b096e0e088dcffd9360effdaa7 +R 460df5fa70f5b978400f9f41b6eef0a4 U drh -Z c5a5cf144ead5527e6e37b4c187e37f0 +Z a4e1f535f3f3f44fafce7d2809ef8d9a diff --git a/manifest.uuid b/manifest.uuid index e9e6ac76c6..65378f6374 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1ebcde72e2046dffaa408d2a5a4a5bbf35fdf4b096e0e088dcffd9360effdaa7 \ No newline at end of file +f2f279b2cc1c8b3b162058c33956be4037cd519715ac0c4290f10c58d2528f0a \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index edf17cae74..d4e157a1cd 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -917,8 +917,11 @@ void FindStates(struct lemon *lemp) lemp->errorcnt++; sp = lemp->startRule->lhs; } - }else{ + }else if( lemp->startRule ){ sp = lemp->startRule->lhs; + }else{ + ErrorMsg(lemp->filename,0,"Internal error - no start rule\n"); + exit(1); } /* Make sure the start symbol doesn't occur on the right-hand side of @@ -1083,7 +1086,7 @@ void FindLinks(struct lemon *lemp) ** which the link is attached. */ for(i=0; instate; i++){ stp = lemp->sorted[i]; - for(cfp=stp->cfp; cfp; cfp=cfp->next){ + for(cfp=stp?stp->cfp:0; cfp; cfp=cfp->next){ cfp->stp = stp; } } @@ -1092,7 +1095,7 @@ void FindLinks(struct lemon *lemp) ** links are used in the follow-set computation. */ for(i=0; instate; i++){ stp = lemp->sorted[i]; - for(cfp=stp->cfp; cfp; cfp=cfp->next){ + for(cfp=stp?stp->cfp:0; cfp; cfp=cfp->next){ for(plp=cfp->bplp; plp; plp=plp->next){ other = plp->cfp; Plink_add(&other->fplp,cfp); @@ -1115,6 +1118,7 @@ void FindFollowSets(struct lemon *lemp) int change; for(i=0; instate; i++){ + assert( lemp->sorted[i]!=0 ); for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){ cfp->status = INCOMPLETE; } @@ -1123,6 +1127,7 @@ void FindFollowSets(struct lemon *lemp) do{ progress = 0; for(i=0; instate; i++){ + assert( lemp->sorted[i]!=0 ); for(cfp=lemp->sorted[i]->cfp; cfp; cfp=cfp->next){ if( cfp->status==COMPLETE ) continue; for(plp=cfp->fplp; plp; plp=plp->next){ @@ -1172,7 +1177,14 @@ void FindActions(struct lemon *lemp) /* Add the accepting token */ if( lemp->start ){ sp = Symbol_find(lemp->start); - if( sp==0 ) sp = lemp->startRule->lhs; + if( sp==0 ){ + if( lemp->startRule==0 ){ + fprintf(stderr, "internal error on source line %d: no start rule\n", + __LINE__); + exit(1); + } + sp = lemp->startRule->lhs; + } }else{ sp = lemp->startRule->lhs; } @@ -1299,21 +1311,7 @@ static struct config **basisend = 0; /* End of list of basis configs */ /* Return a pointer to a new configuration */ PRIVATE struct config *newconfig(void){ - struct config *newcfg; - if( freelist==0 ){ - int i; - int amt = 3; - freelist = (struct config *)calloc( amt, sizeof(struct config) ); - if( freelist==0 ){ - fprintf(stderr,"Unable to allocate memory for a new configuration."); - exit(1); - } - for(i=0; inext; - return newcfg; + return (struct config*)calloc(1, sizeof(struct config)); } /* The configuration "old" is no longer used */ @@ -1932,8 +1930,12 @@ static FILE *errstream; static void errline(int n, int k, FILE *err) { int spcnt, i; - if( g_argv[0] ) fprintf(err,"%s",g_argv[0]); - spcnt = lemonStrlen(g_argv[0]) + 1; + if( g_argv[0] ){ + fprintf(err,"%s",g_argv[0]); + spcnt = lemonStrlen(g_argv[0]) + 1; + }else{ + spcnt = 0; + } for(i=1; ifrom = &(array.ht[h]); array.ht[h] = newnp; } - free(x1a->tbl); + /* free(x1a->tbl); // This program was originally for 16-bit machines. + ** Don't worry about freeing memory on modern platforms. */ *x1a = array; } /* Insert the new data */ @@ -5507,7 +5510,9 @@ int Symbol_insert(struct symbol *data, const char *key) newnp->from = &(array.ht[h]); array.ht[h] = newnp; } - free(x2a->tbl); + /* free(x2a->tbl); // This program was originally written for 16-bit + ** machines. Don't worry about freeing this trivial amount of memory + ** on modern platforms. Just leak it. */ *x2a = array; } /* Insert the new data */ @@ -5843,7 +5848,9 @@ int Configtable_insert(struct config *data) newnp->from = &(array.ht[h]); array.ht[h] = newnp; } - free(x4a->tbl); + /* free(x4a->tbl); // This code was originall written for 16-bit machines. + ** on modern machines, don't worry about freeing this trival amount of + ** memory. */ *x4a = array; } /* Insert the new data */ diff --git a/tool/mkkeywordhash.c b/tool/mkkeywordhash.c index a330ef0c87..fe25b5abc0 100644 --- a/tool/mkkeywordhash.c +++ b/tool/mkkeywordhash.c @@ -513,6 +513,7 @@ int main(int argc, char **argv){ bestSize = nKeyword; bestCount = nKeyword*nKeyword; for(i=nKeyword/2; i<=2*nKeyword; i++){ + if( i<=0 ) continue; for(j=0; j