Fossil SCM

Attempt to fix various harmless compiler warnings reported by Clang-15.

drh 2023-02-03 15:15 trunk
Commit e486a0acbcf055644b1c3d8ac987c6b963baab82d57826256e8b71f6cc1fcaa2
--- src/browse.c
+++ src/browse.c
@@ -660,11 +660,10 @@
660660
Blob dirname;
661661
Manifest *pM = 0;
662662
double rNow = 0;
663663
char *zNow = 0;
664664
int useMtime = atoi(PD("mtime","0"));
665
- int nFile = 0; /* Number of files (or folders with "nofiles") */
666665
int linkTrunk = 1; /* include link to "trunk" */
667666
int linkTip = 1; /* include link to "tip" */
668667
const char *zRE; /* the value for the re=REGEXP query parameter */
669668
const char *zObjType; /* "files" by default or "folders" for "nofiles" */
670669
char *zREx = ""; /* Extra parameters for path hyperlinks */
@@ -802,11 +801,10 @@
802801
if( nD>0 && (fossil_strncmp(zFile, zD, nD-1)!=0 || zFile[nD-1]!='/') ){
803802
continue;
804803
}
805804
if( pRE && re_match(pRE, (const unsigned char*)zFile, -1)==0 ) continue;
806805
tree_add_node(&sTree, zFile, zUuid, mtime);
807
- nFile++;
808806
}
809807
db_finalize(&q);
810808
}else{
811809
Stmt q;
812810
db_prepare(&q,
@@ -824,20 +822,16 @@
824822
if( nD>0 && (fossil_strncmp(zName, zD, nD-1)!=0 || zName[nD-1]!='/') ){
825823
continue;
826824
}
827825
if( pRE && re_match(pRE, (const u8*)zName, -1)==0 ) continue;
828826
tree_add_node(&sTree, zName, zUuid, mtime);
829
- nFile++;
830827
}
831828
db_finalize(&q);
832829
}
833830
style_submenu_checkbox("nofiles", "Folders Only", 0, 0);
834831
835832
if( showDirOnly ){
836
- for(nFile=0, p=sTree.pFirst; p; p=p->pNext){
837
- if( p->pChild!=0 && p->nFullName>nD ) nFile++;
838
- }
839833
zObjType = "Folders";
840834
}else{
841835
zObjType = "Files";
842836
}
843837
844838
--- src/browse.c
+++ src/browse.c
@@ -660,11 +660,10 @@
660 Blob dirname;
661 Manifest *pM = 0;
662 double rNow = 0;
663 char *zNow = 0;
664 int useMtime = atoi(PD("mtime","0"));
665 int nFile = 0; /* Number of files (or folders with "nofiles") */
666 int linkTrunk = 1; /* include link to "trunk" */
667 int linkTip = 1; /* include link to "tip" */
668 const char *zRE; /* the value for the re=REGEXP query parameter */
669 const char *zObjType; /* "files" by default or "folders" for "nofiles" */
670 char *zREx = ""; /* Extra parameters for path hyperlinks */
@@ -802,11 +801,10 @@
802 if( nD>0 && (fossil_strncmp(zFile, zD, nD-1)!=0 || zFile[nD-1]!='/') ){
803 continue;
804 }
805 if( pRE && re_match(pRE, (const unsigned char*)zFile, -1)==0 ) continue;
806 tree_add_node(&sTree, zFile, zUuid, mtime);
807 nFile++;
808 }
809 db_finalize(&q);
810 }else{
811 Stmt q;
812 db_prepare(&q,
@@ -824,20 +822,16 @@
824 if( nD>0 && (fossil_strncmp(zName, zD, nD-1)!=0 || zName[nD-1]!='/') ){
825 continue;
826 }
827 if( pRE && re_match(pRE, (const u8*)zName, -1)==0 ) continue;
828 tree_add_node(&sTree, zName, zUuid, mtime);
829 nFile++;
830 }
831 db_finalize(&q);
832 }
833 style_submenu_checkbox("nofiles", "Folders Only", 0, 0);
834
835 if( showDirOnly ){
836 for(nFile=0, p=sTree.pFirst; p; p=p->pNext){
837 if( p->pChild!=0 && p->nFullName>nD ) nFile++;
838 }
839 zObjType = "Folders";
840 }else{
841 zObjType = "Files";
842 }
843
844
--- src/browse.c
+++ src/browse.c
@@ -660,11 +660,10 @@
660 Blob dirname;
661 Manifest *pM = 0;
662 double rNow = 0;
663 char *zNow = 0;
664 int useMtime = atoi(PD("mtime","0"));
 
665 int linkTrunk = 1; /* include link to "trunk" */
666 int linkTip = 1; /* include link to "tip" */
667 const char *zRE; /* the value for the re=REGEXP query parameter */
668 const char *zObjType; /* "files" by default or "folders" for "nofiles" */
669 char *zREx = ""; /* Extra parameters for path hyperlinks */
@@ -802,11 +801,10 @@
801 if( nD>0 && (fossil_strncmp(zFile, zD, nD-1)!=0 || zFile[nD-1]!='/') ){
802 continue;
803 }
804 if( pRE && re_match(pRE, (const unsigned char*)zFile, -1)==0 ) continue;
805 tree_add_node(&sTree, zFile, zUuid, mtime);
 
806 }
807 db_finalize(&q);
808 }else{
809 Stmt q;
810 db_prepare(&q,
@@ -824,20 +822,16 @@
822 if( nD>0 && (fossil_strncmp(zName, zD, nD-1)!=0 || zName[nD-1]!='/') ){
823 continue;
824 }
825 if( pRE && re_match(pRE, (const u8*)zName, -1)==0 ) continue;
826 tree_add_node(&sTree, zName, zUuid, mtime);
 
827 }
828 db_finalize(&q);
829 }
830 style_submenu_checkbox("nofiles", "Folders Only", 0, 0);
831
832 if( showDirOnly ){
 
 
 
833 zObjType = "Folders";
834 }else{
835 zObjType = "Files";
836 }
837
838
+2 -4
--- src/diff.c
+++ src/diff.c
@@ -409,11 +409,10 @@
409409
int mxr; /* Maximum value for r */
410410
int na, nb; /* Number of lines shown from A and B */
411411
int i, j; /* Loop counters */
412412
int m; /* Number of lines to output */
413413
int skip; /* Number of lines to skip */
414
- static int nChunk = 0; /* Number of diff chunks seen so far */
415414
int nContext; /* Number of lines of context */
416415
int showLn; /* Show line numbers */
417416
int showDivider = 0; /* True to show the divider between diff blocks */
418417
419418
nContext = diff_context_lines(pCfg);
@@ -2070,11 +2069,11 @@
20702069
){
20712070
int i, j, k; /* Loop counters */
20722071
int *a; /* One row of the Wagner matrix */
20732072
int *pToFree; /* Space that needs to be freed */
20742073
unsigned char *aM; /* Wagner result matrix */
2075
- int nMatch, iMatch; /* Number of matching lines and match score */
2074
+ int iMatch; /* Matching match score */
20762075
int aBuf[100]; /* Stack space for a[] if nRight not to big */
20772076
20782077
if( nLeft==0 ){
20792078
aM = fossil_malloc( nRight + 2 );
20802079
memset(aM, 2, nRight);
@@ -2152,18 +2151,17 @@
21522151
21532152
/* Compute the lowest-cost path back through the matrix */
21542153
i = nRight;
21552154
j = nLeft;
21562155
k = (nRight+1)*(nLeft+1)-1;
2157
- nMatch = iMatch = 0;
2156
+ iMatch = 0;
21582157
while( i+j>0 ){
21592158
unsigned char c = aM[k];
21602159
if( c>=3 ){
21612160
assert( i>0 && j>0 );
21622161
i--;
21632162
j--;
2164
- nMatch++;
21652163
iMatch += (c>>2);
21662164
aM[k] = 3;
21672165
}else if( c==2 ){
21682166
assert( i>0 );
21692167
i--;
21702168
--- src/diff.c
+++ src/diff.c
@@ -409,11 +409,10 @@
409 int mxr; /* Maximum value for r */
410 int na, nb; /* Number of lines shown from A and B */
411 int i, j; /* Loop counters */
412 int m; /* Number of lines to output */
413 int skip; /* Number of lines to skip */
414 static int nChunk = 0; /* Number of diff chunks seen so far */
415 int nContext; /* Number of lines of context */
416 int showLn; /* Show line numbers */
417 int showDivider = 0; /* True to show the divider between diff blocks */
418
419 nContext = diff_context_lines(pCfg);
@@ -2070,11 +2069,11 @@
2070 ){
2071 int i, j, k; /* Loop counters */
2072 int *a; /* One row of the Wagner matrix */
2073 int *pToFree; /* Space that needs to be freed */
2074 unsigned char *aM; /* Wagner result matrix */
2075 int nMatch, iMatch; /* Number of matching lines and match score */
2076 int aBuf[100]; /* Stack space for a[] if nRight not to big */
2077
2078 if( nLeft==0 ){
2079 aM = fossil_malloc( nRight + 2 );
2080 memset(aM, 2, nRight);
@@ -2152,18 +2151,17 @@
2152
2153 /* Compute the lowest-cost path back through the matrix */
2154 i = nRight;
2155 j = nLeft;
2156 k = (nRight+1)*(nLeft+1)-1;
2157 nMatch = iMatch = 0;
2158 while( i+j>0 ){
2159 unsigned char c = aM[k];
2160 if( c>=3 ){
2161 assert( i>0 && j>0 );
2162 i--;
2163 j--;
2164 nMatch++;
2165 iMatch += (c>>2);
2166 aM[k] = 3;
2167 }else if( c==2 ){
2168 assert( i>0 );
2169 i--;
2170
--- src/diff.c
+++ src/diff.c
@@ -409,11 +409,10 @@
409 int mxr; /* Maximum value for r */
410 int na, nb; /* Number of lines shown from A and B */
411 int i, j; /* Loop counters */
412 int m; /* Number of lines to output */
413 int skip; /* Number of lines to skip */
 
414 int nContext; /* Number of lines of context */
415 int showLn; /* Show line numbers */
416 int showDivider = 0; /* True to show the divider between diff blocks */
417
418 nContext = diff_context_lines(pCfg);
@@ -2070,11 +2069,11 @@
2069 ){
2070 int i, j, k; /* Loop counters */
2071 int *a; /* One row of the Wagner matrix */
2072 int *pToFree; /* Space that needs to be freed */
2073 unsigned char *aM; /* Wagner result matrix */
2074 int iMatch; /* Matching match score */
2075 int aBuf[100]; /* Stack space for a[] if nRight not to big */
2076
2077 if( nLeft==0 ){
2078 aM = fossil_malloc( nRight + 2 );
2079 memset(aM, 2, nRight);
@@ -2152,18 +2151,17 @@
2151
2152 /* Compute the lowest-cost path back through the matrix */
2153 i = nRight;
2154 j = nLeft;
2155 k = (nRight+1)*(nLeft+1)-1;
2156 iMatch = 0;
2157 while( i+j>0 ){
2158 unsigned char c = aM[k];
2159 if( c>=3 ){
2160 assert( i>0 && j>0 );
2161 i--;
2162 j--;
 
2163 iMatch += (c>>2);
2164 aM[k] = 3;
2165 }else if( c==2 ){
2166 assert( i>0 );
2167 i--;
2168
+2 -3
--- src/popen.c
+++ src/popen.c
@@ -183,20 +183,19 @@
183183
return 1;
184184
}
185185
signal(SIGPIPE,SIG_IGN);
186186
if( *pChildPid==0 ){
187187
int fd;
188
- int nErr = 0;
189188
/* This is the child process */
190189
close(0);
191190
fd = dup(pout[0]);
192
- if( fd!=0 ) nErr++;
191
+ if( fd!=0 ) fossil_panic("popen() failed to open file descriptor 0");
193192
close(pout[0]);
194193
close(pout[1]);
195194
close(1);
196195
fd = dup(pin[1]);
197
- if( fd!=1 ) nErr++;
196
+ if( fd!=1 ) fossil_panic("popen() failed to open file descriptor 1");
198197
close(pin[0]);
199198
close(pin[1]);
200199
if( bDirect ){
201200
execl(zCmd, zCmd, (char*)0);
202201
}else{
203202
--- src/popen.c
+++ src/popen.c
@@ -183,20 +183,19 @@
183 return 1;
184 }
185 signal(SIGPIPE,SIG_IGN);
186 if( *pChildPid==0 ){
187 int fd;
188 int nErr = 0;
189 /* This is the child process */
190 close(0);
191 fd = dup(pout[0]);
192 if( fd!=0 ) nErr++;
193 close(pout[0]);
194 close(pout[1]);
195 close(1);
196 fd = dup(pin[1]);
197 if( fd!=1 ) nErr++;
198 close(pin[0]);
199 close(pin[1]);
200 if( bDirect ){
201 execl(zCmd, zCmd, (char*)0);
202 }else{
203
--- src/popen.c
+++ src/popen.c
@@ -183,20 +183,19 @@
183 return 1;
184 }
185 signal(SIGPIPE,SIG_IGN);
186 if( *pChildPid==0 ){
187 int fd;
 
188 /* This is the child process */
189 close(0);
190 fd = dup(pout[0]);
191 if( fd!=0 ) fossil_panic("popen() failed to open file descriptor 0");
192 close(pout[0]);
193 close(pout[1]);
194 close(1);
195 fd = dup(pin[1]);
196 if( fd!=1 ) fossil_panic("popen() failed to open file descriptor 1");
197 close(pin[0]);
198 close(pin[1]);
199 if( bDirect ){
200 execl(zCmd, zCmd, (char*)0);
201 }else{
202
--- src/report.c
+++ src/report.c
@@ -45,11 +45,10 @@
4545
void view_list(void){
4646
const char *zScript;
4747
Blob ril; /* Report Item List */
4848
Stmt q;
4949
int rn = 0;
50
- int cnt = 0;
5150
char *defaultReport = db_get("ticket-default-report", 0);
5251
5352
login_check_credentials();
5453
if( !g.perm.RdTkt && !g.perm.NewTkt ){
5554
login_needed(g.anon.RdTkt || g.anon.NewTkt);
@@ -70,11 +69,10 @@
7069
const char *zOwner = db_column_text(&q, 2);
7170
if( zTitle[0] =='_' && !g.perm.TktFmt ){
7271
continue;
7372
}
7473
rn = db_column_int(&q, 0);
75
- cnt++;
7674
blob_appendf(&ril, "<li>");
7775
if( zTitle[0] == '_' ){
7876
blob_appendf(&ril, "%s", zTitle);
7977
} else {
8078
blob_appendf(&ril, "%z%h</a>", href("%R/rptview/%d", rn), zTitle);
8179
--- src/report.c
+++ src/report.c
@@ -45,11 +45,10 @@
45 void view_list(void){
46 const char *zScript;
47 Blob ril; /* Report Item List */
48 Stmt q;
49 int rn = 0;
50 int cnt = 0;
51 char *defaultReport = db_get("ticket-default-report", 0);
52
53 login_check_credentials();
54 if( !g.perm.RdTkt && !g.perm.NewTkt ){
55 login_needed(g.anon.RdTkt || g.anon.NewTkt);
@@ -70,11 +69,10 @@
70 const char *zOwner = db_column_text(&q, 2);
71 if( zTitle[0] =='_' && !g.perm.TktFmt ){
72 continue;
73 }
74 rn = db_column_int(&q, 0);
75 cnt++;
76 blob_appendf(&ril, "<li>");
77 if( zTitle[0] == '_' ){
78 blob_appendf(&ril, "%s", zTitle);
79 } else {
80 blob_appendf(&ril, "%z%h</a>", href("%R/rptview/%d", rn), zTitle);
81
--- src/report.c
+++ src/report.c
@@ -45,11 +45,10 @@
45 void view_list(void){
46 const char *zScript;
47 Blob ril; /* Report Item List */
48 Stmt q;
49 int rn = 0;
 
50 char *defaultReport = db_get("ticket-default-report", 0);
51
52 login_check_credentials();
53 if( !g.perm.RdTkt && !g.perm.NewTkt ){
54 login_needed(g.anon.RdTkt || g.anon.NewTkt);
@@ -70,11 +69,10 @@
69 const char *zOwner = db_column_text(&q, 2);
70 if( zTitle[0] =='_' && !g.perm.TktFmt ){
71 continue;
72 }
73 rn = db_column_int(&q, 0);
 
74 blob_appendf(&ril, "<li>");
75 if( zTitle[0] == '_' ){
76 blob_appendf(&ril, "%s", zTitle);
77 } else {
78 blob_appendf(&ril, "%z%h</a>", href("%R/rptview/%d", rn), zTitle);
79
+2 -2
--- src/th_lang.c
+++ src/th_lang.c
@@ -1370,12 +1370,12 @@
13701370
void *ctx,
13711371
int argc,
13721372
const char **argv,
13731373
int *argl
13741374
){
1375
- int cnt = 0;
1376
- cnt++;
1375
+ static unsigned int cnt = 0;
1376
+ if( (cnt++)==0xffffffff ) printf("too many TH3 breakpoints\n");
13771377
return TH_OK;
13781378
}
13791379
13801380
/*
13811381
** Register the built-in th1 language commands with interpreter interp.
13821382
--- src/th_lang.c
+++ src/th_lang.c
@@ -1370,12 +1370,12 @@
1370 void *ctx,
1371 int argc,
1372 const char **argv,
1373 int *argl
1374 ){
1375 int cnt = 0;
1376 cnt++;
1377 return TH_OK;
1378 }
1379
1380 /*
1381 ** Register the built-in th1 language commands with interpreter interp.
1382
--- src/th_lang.c
+++ src/th_lang.c
@@ -1370,12 +1370,12 @@
1370 void *ctx,
1371 int argc,
1372 const char **argv,
1373 int *argl
1374 ){
1375 static unsigned int cnt = 0;
1376 if( (cnt++)==0xffffffff ) printf("too many TH3 breakpoints\n");
1377 return TH_OK;
1378 }
1379
1380 /*
1381 ** Register the built-in th1 language commands with interpreter interp.
1382
+1 -3
--- src/xfer.c
+++ src/xfer.c
@@ -1063,11 +1063,10 @@
10631063
** If HASH is different from the unversioned content hash on this server,
10641064
** then send a bunch of uvigot cards, one for each entry unversioned file
10651065
** on this server.
10661066
*/
10671067
static void send_unversioned_catalog(Xfer *pXfer){
1068
- int nUvIgot = 0;
10691068
Stmt uvq;
10701069
unversioned_schema();
10711070
db_prepare(&uvq,
10721071
"SELECT name, mtime, hash, sz FROM unversioned"
10731072
);
@@ -1074,11 +1073,10 @@
10741073
while( db_step(&uvq)==SQLITE_ROW ){
10751074
const char *zName = db_column_text(&uvq,0);
10761075
sqlite3_int64 mtime = db_column_int64(&uvq,1);
10771076
const char *zHash = db_column_text(&uvq,2);
10781077
int sz = db_column_int(&uvq,3);
1079
- nUvIgot++;
10801078
if( zHash==0 ){ sz = 0; zHash = "-"; }
10811079
blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n",
10821080
zName, mtime, zHash, sz);
10831081
}
10841082
db_finalize(&uvq);
@@ -1840,11 +1838,11 @@
18401838
18411839
/* Send the server timestamp last, in case prior processing happened
18421840
** to use up a significant fraction of our time window.
18431841
*/
18441842
zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
1845
- @ # timestamp %s(zNow)
1843
+ @ # timestamp %s(zNow) errors %d(nErr)
18461844
free(zNow);
18471845
18481846
db_commit_transaction();
18491847
configure_rebuild();
18501848
}
18511849
--- src/xfer.c
+++ src/xfer.c
@@ -1063,11 +1063,10 @@
1063 ** If HASH is different from the unversioned content hash on this server,
1064 ** then send a bunch of uvigot cards, one for each entry unversioned file
1065 ** on this server.
1066 */
1067 static void send_unversioned_catalog(Xfer *pXfer){
1068 int nUvIgot = 0;
1069 Stmt uvq;
1070 unversioned_schema();
1071 db_prepare(&uvq,
1072 "SELECT name, mtime, hash, sz FROM unversioned"
1073 );
@@ -1074,11 +1073,10 @@
1074 while( db_step(&uvq)==SQLITE_ROW ){
1075 const char *zName = db_column_text(&uvq,0);
1076 sqlite3_int64 mtime = db_column_int64(&uvq,1);
1077 const char *zHash = db_column_text(&uvq,2);
1078 int sz = db_column_int(&uvq,3);
1079 nUvIgot++;
1080 if( zHash==0 ){ sz = 0; zHash = "-"; }
1081 blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n",
1082 zName, mtime, zHash, sz);
1083 }
1084 db_finalize(&uvq);
@@ -1840,11 +1838,11 @@
1840
1841 /* Send the server timestamp last, in case prior processing happened
1842 ** to use up a significant fraction of our time window.
1843 */
1844 zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
1845 @ # timestamp %s(zNow)
1846 free(zNow);
1847
1848 db_commit_transaction();
1849 configure_rebuild();
1850 }
1851
--- src/xfer.c
+++ src/xfer.c
@@ -1063,11 +1063,10 @@
1063 ** If HASH is different from the unversioned content hash on this server,
1064 ** then send a bunch of uvigot cards, one for each entry unversioned file
1065 ** on this server.
1066 */
1067 static void send_unversioned_catalog(Xfer *pXfer){
 
1068 Stmt uvq;
1069 unversioned_schema();
1070 db_prepare(&uvq,
1071 "SELECT name, mtime, hash, sz FROM unversioned"
1072 );
@@ -1074,11 +1073,10 @@
1073 while( db_step(&uvq)==SQLITE_ROW ){
1074 const char *zName = db_column_text(&uvq,0);
1075 sqlite3_int64 mtime = db_column_int64(&uvq,1);
1076 const char *zHash = db_column_text(&uvq,2);
1077 int sz = db_column_int(&uvq,3);
 
1078 if( zHash==0 ){ sz = 0; zHash = "-"; }
1079 blob_appendf(pXfer->pOut, "uvigot %s %lld %s %d\n",
1080 zName, mtime, zHash, sz);
1081 }
1082 db_finalize(&uvq);
@@ -1840,11 +1838,11 @@
1838
1839 /* Send the server timestamp last, in case prior processing happened
1840 ** to use up a significant fraction of our time window.
1841 */
1842 zNow = db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%S', 'now')");
1843 @ # timestamp %s(zNow) errors %d(nErr)
1844 free(zNow);
1845
1846 db_commit_transaction();
1847 configure_rebuild();
1848 }
1849

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button