Fossil SCM

Fix a few **unused-but-set-variable** warnings. (reported by recent clang on MacOS at least). Also fix a **warn_unused_result** warning when calling nice() (gcc 7.5.0 on Ubuntu-18.04 and gcc 9.3.0 on Ubuntu-20.04)

mgagnon 2022-04-26 14:27 trunk
Commit 74250821b1f4b080730e442bb7ce260434235198e02df277b2dbae0da28d4439
-19
--- src/diff.c
+++ src/diff.c
@@ -2211,11 +2211,10 @@
22112211
unsigned int b = 0; /* Index of next line in B[] */
22122212
const int *R; /* Array of COPY/DELETE/INSERT triples */
22132213
unsigned int r; /* Index into R[] */
22142214
unsigned int nr; /* Number of COPY/DELETE/INSERT triples to process */
22152215
unsigned int mxr; /* Maximum value for r */
2216
- unsigned int na, nb; /* Number of lines shown from A and B */
22172216
unsigned int i, j; /* Loop counters */
22182217
unsigned int m, ma, mb;/* Number of lines to output */
22192218
signed int skip = 0; /* Number of lines to skip */
22202219
unsigned int nContext; /* Lines of context above and below each change */
22212220
@@ -2257,32 +2256,14 @@
22572256
22582257
/* Figure out how many lines of A and B are to be displayed
22592258
** for this change block.
22602259
*/
22612260
if( R[r]>nContext ){
2262
- na = nb = nContext;
22632261
skip = R[r] - nContext;
22642262
}else{
2265
- na = nb = R[r];
22662263
skip = 0;
22672264
}
2268
- for(i=0; i<nr; i++){
2269
- na += R[r+i*3+1];
2270
- nb += R[r+i*3+2];
2271
- }
2272
- if( R[r+nr*3]>nContext ){
2273
- na += nContext;
2274
- nb += nContext;
2275
- }else{
2276
- na += R[r+nr*3];
2277
- nb += R[r+nr*3];
2278
- }
2279
- for(i=1; i<nr; i++){
2280
- na += R[r+i*3];
2281
- nb += R[r+i*3];
2282
- }
2283
-
22842265
/* Show the initial common area */
22852266
a += skip;
22862267
b += skip;
22872268
m = R[r] - skip;
22882269
if( r ) skip -= nContext;
22892270
--- src/diff.c
+++ src/diff.c
@@ -2211,11 +2211,10 @@
2211 unsigned int b = 0; /* Index of next line in B[] */
2212 const int *R; /* Array of COPY/DELETE/INSERT triples */
2213 unsigned int r; /* Index into R[] */
2214 unsigned int nr; /* Number of COPY/DELETE/INSERT triples to process */
2215 unsigned int mxr; /* Maximum value for r */
2216 unsigned int na, nb; /* Number of lines shown from A and B */
2217 unsigned int i, j; /* Loop counters */
2218 unsigned int m, ma, mb;/* Number of lines to output */
2219 signed int skip = 0; /* Number of lines to skip */
2220 unsigned int nContext; /* Lines of context above and below each change */
2221
@@ -2257,32 +2256,14 @@
2257
2258 /* Figure out how many lines of A and B are to be displayed
2259 ** for this change block.
2260 */
2261 if( R[r]>nContext ){
2262 na = nb = nContext;
2263 skip = R[r] - nContext;
2264 }else{
2265 na = nb = R[r];
2266 skip = 0;
2267 }
2268 for(i=0; i<nr; i++){
2269 na += R[r+i*3+1];
2270 nb += R[r+i*3+2];
2271 }
2272 if( R[r+nr*3]>nContext ){
2273 na += nContext;
2274 nb += nContext;
2275 }else{
2276 na += R[r+nr*3];
2277 nb += R[r+nr*3];
2278 }
2279 for(i=1; i<nr; i++){
2280 na += R[r+i*3];
2281 nb += R[r+i*3];
2282 }
2283
2284 /* Show the initial common area */
2285 a += skip;
2286 b += skip;
2287 m = R[r] - skip;
2288 if( r ) skip -= nContext;
2289
--- src/diff.c
+++ src/diff.c
@@ -2211,11 +2211,10 @@
2211 unsigned int b = 0; /* Index of next line in B[] */
2212 const int *R; /* Array of COPY/DELETE/INSERT triples */
2213 unsigned int r; /* Index into R[] */
2214 unsigned int nr; /* Number of COPY/DELETE/INSERT triples to process */
2215 unsigned int mxr; /* Maximum value for r */
 
2216 unsigned int i, j; /* Loop counters */
2217 unsigned int m, ma, mb;/* Number of lines to output */
2218 signed int skip = 0; /* Number of lines to skip */
2219 unsigned int nContext; /* Lines of context above and below each change */
2220
@@ -2257,32 +2256,14 @@
2256
2257 /* Figure out how many lines of A and B are to be displayed
2258 ** for this change block.
2259 */
2260 if( R[r]>nContext ){
 
2261 skip = R[r] - nContext;
2262 }else{
 
2263 skip = 0;
2264 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2265 /* Show the initial common area */
2266 a += skip;
2267 b += skip;
2268 m = R[r] - skip;
2269 if( r ) skip -= nContext;
2270
+1 -3
--- src/name.c
+++ src/name.c
@@ -1751,11 +1751,11 @@
17511751
/*
17521752
** Generate a report on the number of collisions in artifact hashes
17531753
** generated by the SQL given in the argument.
17541754
*/
17551755
static void collision_report(const char *zSql){
1756
- int i, j, kk;
1756
+ int i, j;
17571757
int nHash = 0;
17581758
Stmt q;
17591759
char zPrev[HNAME_MAX+1];
17601760
struct {
17611761
int cnt;
@@ -1788,15 +1788,13 @@
17881788
if( aCollide[i].cnt==0 ) continue;
17891789
@ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr>
17901790
}
17911791
@ </tbody></table>
17921792
@ <p>Total number of hashes: %d(nHash)</p>
1793
- kk = 0;
17941793
for(i=HNAME_MAX; i>=4; i--){
17951794
if( aCollide[i].cnt==0 ) continue;
17961795
if( aCollide[i].cnt>200 ) break;
1797
- kk += aCollide[i].cnt;
17981796
if( aCollide[i].cnt<25 ){
17991797
@ <p>Collisions of length %d(i):
18001798
}else{
18011799
@ <p>First 25 collisions of length %d(i):
18021800
}
18031801
--- src/name.c
+++ src/name.c
@@ -1751,11 +1751,11 @@
1751 /*
1752 ** Generate a report on the number of collisions in artifact hashes
1753 ** generated by the SQL given in the argument.
1754 */
1755 static void collision_report(const char *zSql){
1756 int i, j, kk;
1757 int nHash = 0;
1758 Stmt q;
1759 char zPrev[HNAME_MAX+1];
1760 struct {
1761 int cnt;
@@ -1788,15 +1788,13 @@
1788 if( aCollide[i].cnt==0 ) continue;
1789 @ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr>
1790 }
1791 @ </tbody></table>
1792 @ <p>Total number of hashes: %d(nHash)</p>
1793 kk = 0;
1794 for(i=HNAME_MAX; i>=4; i--){
1795 if( aCollide[i].cnt==0 ) continue;
1796 if( aCollide[i].cnt>200 ) break;
1797 kk += aCollide[i].cnt;
1798 if( aCollide[i].cnt<25 ){
1799 @ <p>Collisions of length %d(i):
1800 }else{
1801 @ <p>First 25 collisions of length %d(i):
1802 }
1803
--- src/name.c
+++ src/name.c
@@ -1751,11 +1751,11 @@
1751 /*
1752 ** Generate a report on the number of collisions in artifact hashes
1753 ** generated by the SQL given in the argument.
1754 */
1755 static void collision_report(const char *zSql){
1756 int i, j;
1757 int nHash = 0;
1758 Stmt q;
1759 char zPrev[HNAME_MAX+1];
1760 struct {
1761 int cnt;
@@ -1788,15 +1788,13 @@
1788 if( aCollide[i].cnt==0 ) continue;
1789 @ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr>
1790 }
1791 @ </tbody></table>
1792 @ <p>Total number of hashes: %d(nHash)</p>
 
1793 for(i=HNAME_MAX; i>=4; i--){
1794 if( aCollide[i].cnt==0 ) continue;
1795 if( aCollide[i].cnt>200 ) break;
 
1796 if( aCollide[i].cnt<25 ){
1797 @ <p>Collisions of length %d(i):
1798 }else{
1799 @ <p>First 25 collisions of length %d(i):
1800 }
1801
--- src/statrep.c
+++ src/statrep.c
@@ -344,11 +344,10 @@
344344
** Implements the "byuser" view for /reports.
345345
*/
346346
static void stats_report_by_user(){
347347
Stmt query = empty_Stmt;
348348
int nRowNumber = 0; /* current TR number */
349
- int nEventTotal = 0; /* Total event count */
350349
int rowClass = 0; /* counter for alternating
351350
row colors */
352351
int nMaxEvents = 1; /* max number of events for
353352
all rows. */
354353
stats_report_init_view();
@@ -392,11 +391,10 @@
392391
? (int)(100 * nCount / nMaxEvents)
393392
: 0;
394393
if(!nCount) continue /* arguable! Possible? */;
395394
else if(!nSize) nSize = 1;
396395
rowClass = ++nRowNumber % 2;
397
- nEventTotal += nCount;
398396
@ <tr class='row%d(rowClass)'>
399397
@ <td>
400398
@ <a href="?view=bymonth&user=%h(zUser)&type=%c(y)">%h(zUser)</a>
401399
@ </td><td data-sortkey='%08x(-nCount)'>%d(nCount)</td>
402400
@ <td>
@@ -475,11 +473,10 @@
475473
** the report is restricted to events created by the named user account.
476474
*/
477475
static void stats_report_day_of_week(const char *zUserName){
478476
Stmt query = empty_Stmt;
479477
int nRowNumber = 0; /* current TR number */
480
- int nEventTotal = 0; /* Total event count */
481478
int rowClass = 0; /* counter for alternating
482479
row colors */
483480
int nMaxEvents = 1; /* max number of events for
484481
all rows. */
485482
Blob userFilter = empty_blob; /* Optional user=johndoe query string */
@@ -549,11 +546,10 @@
549546
? (int)(100 * nCount / nMaxEvents)
550547
: 0;
551548
if(!nCount) continue /* arguable! Possible? */;
552549
else if(!nSize) nSize = 1;
553550
rowClass = ++nRowNumber % 2;
554
- nEventTotal += nCount;
555551
@<tr class='row%d(rowClass)'>
556552
@ <td>%d(dayNum)</td>
557553
@ <td>%s(daysOfWeek[dayNum])</td>
558554
@ <td>%d(nCount)</td>
559555
@ <td>
560556
--- src/statrep.c
+++ src/statrep.c
@@ -344,11 +344,10 @@
344 ** Implements the "byuser" view for /reports.
345 */
346 static void stats_report_by_user(){
347 Stmt query = empty_Stmt;
348 int nRowNumber = 0; /* current TR number */
349 int nEventTotal = 0; /* Total event count */
350 int rowClass = 0; /* counter for alternating
351 row colors */
352 int nMaxEvents = 1; /* max number of events for
353 all rows. */
354 stats_report_init_view();
@@ -392,11 +391,10 @@
392 ? (int)(100 * nCount / nMaxEvents)
393 : 0;
394 if(!nCount) continue /* arguable! Possible? */;
395 else if(!nSize) nSize = 1;
396 rowClass = ++nRowNumber % 2;
397 nEventTotal += nCount;
398 @ <tr class='row%d(rowClass)'>
399 @ <td>
400 @ <a href="?view=bymonth&user=%h(zUser)&type=%c(y)">%h(zUser)</a>
401 @ </td><td data-sortkey='%08x(-nCount)'>%d(nCount)</td>
402 @ <td>
@@ -475,11 +473,10 @@
475 ** the report is restricted to events created by the named user account.
476 */
477 static void stats_report_day_of_week(const char *zUserName){
478 Stmt query = empty_Stmt;
479 int nRowNumber = 0; /* current TR number */
480 int nEventTotal = 0; /* Total event count */
481 int rowClass = 0; /* counter for alternating
482 row colors */
483 int nMaxEvents = 1; /* max number of events for
484 all rows. */
485 Blob userFilter = empty_blob; /* Optional user=johndoe query string */
@@ -549,11 +546,10 @@
549 ? (int)(100 * nCount / nMaxEvents)
550 : 0;
551 if(!nCount) continue /* arguable! Possible? */;
552 else if(!nSize) nSize = 1;
553 rowClass = ++nRowNumber % 2;
554 nEventTotal += nCount;
555 @<tr class='row%d(rowClass)'>
556 @ <td>%d(dayNum)</td>
557 @ <td>%s(daysOfWeek[dayNum])</td>
558 @ <td>%d(nCount)</td>
559 @ <td>
560
--- src/statrep.c
+++ src/statrep.c
@@ -344,11 +344,10 @@
344 ** Implements the "byuser" view for /reports.
345 */
346 static void stats_report_by_user(){
347 Stmt query = empty_Stmt;
348 int nRowNumber = 0; /* current TR number */
 
349 int rowClass = 0; /* counter for alternating
350 row colors */
351 int nMaxEvents = 1; /* max number of events for
352 all rows. */
353 stats_report_init_view();
@@ -392,11 +391,10 @@
391 ? (int)(100 * nCount / nMaxEvents)
392 : 0;
393 if(!nCount) continue /* arguable! Possible? */;
394 else if(!nSize) nSize = 1;
395 rowClass = ++nRowNumber % 2;
 
396 @ <tr class='row%d(rowClass)'>
397 @ <td>
398 @ <a href="?view=bymonth&user=%h(zUser)&type=%c(y)">%h(zUser)</a>
399 @ </td><td data-sortkey='%08x(-nCount)'>%d(nCount)</td>
400 @ <td>
@@ -475,11 +473,10 @@
473 ** the report is restricted to events created by the named user account.
474 */
475 static void stats_report_day_of_week(const char *zUserName){
476 Stmt query = empty_Stmt;
477 int nRowNumber = 0; /* current TR number */
 
478 int rowClass = 0; /* counter for alternating
479 row colors */
480 int nMaxEvents = 1; /* max number of events for
481 all rows. */
482 Blob userFilter = empty_blob; /* Optional user=johndoe query string */
@@ -549,11 +546,10 @@
546 ? (int)(100 * nCount / nMaxEvents)
547 : 0;
548 if(!nCount) continue /* arguable! Possible? */;
549 else if(!nSize) nSize = 1;
550 rowClass = ++nRowNumber % 2;
 
551 @<tr class='row%d(rowClass)'>
552 @ <td>%d(dayNum)</td>
553 @ <td>%s(daysOfWeek[dayNum])</td>
554 @ <td>%d(nCount)</td>
555 @ <td>
556
+3 -1
--- src/util.c
+++ src/util.c
@@ -903,11 +903,13 @@
903903
** On non-Windows systems, calls nice(2) with the given level. Errors
904904
** are ignored. On Windows this is a no-op.
905905
*/
906906
void fossil_nice(int level){
907907
#ifndef _WIN32
908
- nice(level);
908
+ /* dummy if() condition to avoid nuisance warning about unused result on
909
+ certain compiler */
910
+ if( nice(level) ){ /*ignored*/ }
909911
#else
910912
(void)level;
911913
#endif
912914
}
913915
914916
--- src/util.c
+++ src/util.c
@@ -903,11 +903,13 @@
903 ** On non-Windows systems, calls nice(2) with the given level. Errors
904 ** are ignored. On Windows this is a no-op.
905 */
906 void fossil_nice(int level){
907 #ifndef _WIN32
908 nice(level);
 
 
909 #else
910 (void)level;
911 #endif
912 }
913
914
--- src/util.c
+++ src/util.c
@@ -903,11 +903,13 @@
903 ** On non-Windows systems, calls nice(2) with the given level. Errors
904 ** are ignored. On Windows this is a no-op.
905 */
906 void fossil_nice(int level){
907 #ifndef _WIN32
908 /* dummy if() condition to avoid nuisance warning about unused result on
909 certain compiler */
910 if( nice(level) ){ /*ignored*/ }
911 #else
912 (void)level;
913 #endif
914 }
915
916

Keyboard Shortcuts

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