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)
Commit
74250821b1f4b080730e442bb7ce260434235198e02df277b2dbae0da28d4439
Parent
fab8d922154df9e…
4 files changed
-19
+1
-3
-4
+3
-1
-19
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -2211,11 +2211,10 @@ | ||
| 2211 | 2211 | unsigned int b = 0; /* Index of next line in B[] */ |
| 2212 | 2212 | const int *R; /* Array of COPY/DELETE/INSERT triples */ |
| 2213 | 2213 | unsigned int r; /* Index into R[] */ |
| 2214 | 2214 | unsigned int nr; /* Number of COPY/DELETE/INSERT triples to process */ |
| 2215 | 2215 | unsigned int mxr; /* Maximum value for r */ |
| 2216 | - unsigned int na, nb; /* Number of lines shown from A and B */ | |
| 2217 | 2216 | unsigned int i, j; /* Loop counters */ |
| 2218 | 2217 | unsigned int m, ma, mb;/* Number of lines to output */ |
| 2219 | 2218 | signed int skip = 0; /* Number of lines to skip */ |
| 2220 | 2219 | unsigned int nContext; /* Lines of context above and below each change */ |
| 2221 | 2220 | |
| @@ -2257,32 +2256,14 @@ | ||
| 2257 | 2256 | |
| 2258 | 2257 | /* Figure out how many lines of A and B are to be displayed |
| 2259 | 2258 | ** for this change block. |
| 2260 | 2259 | */ |
| 2261 | 2260 | if( R[r]>nContext ){ |
| 2262 | - na = nb = nContext; | |
| 2263 | 2261 | skip = R[r] - nContext; |
| 2264 | 2262 | }else{ |
| 2265 | - na = nb = R[r]; | |
| 2266 | 2263 | skip = 0; |
| 2267 | 2264 | } |
| 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 | 2265 | /* Show the initial common area */ |
| 2285 | 2266 | a += skip; |
| 2286 | 2267 | b += skip; |
| 2287 | 2268 | m = R[r] - skip; |
| 2288 | 2269 | if( r ) skip -= nContext; |
| 2289 | 2270 |
| --- 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 @@ | ||
| 1751 | 1751 | /* |
| 1752 | 1752 | ** Generate a report on the number of collisions in artifact hashes |
| 1753 | 1753 | ** generated by the SQL given in the argument. |
| 1754 | 1754 | */ |
| 1755 | 1755 | static void collision_report(const char *zSql){ |
| 1756 | - int i, j, kk; | |
| 1756 | + int i, j; | |
| 1757 | 1757 | int nHash = 0; |
| 1758 | 1758 | Stmt q; |
| 1759 | 1759 | char zPrev[HNAME_MAX+1]; |
| 1760 | 1760 | struct { |
| 1761 | 1761 | int cnt; |
| @@ -1788,15 +1788,13 @@ | ||
| 1788 | 1788 | if( aCollide[i].cnt==0 ) continue; |
| 1789 | 1789 | @ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr> |
| 1790 | 1790 | } |
| 1791 | 1791 | @ </tbody></table> |
| 1792 | 1792 | @ <p>Total number of hashes: %d(nHash)</p> |
| 1793 | - kk = 0; | |
| 1794 | 1793 | for(i=HNAME_MAX; i>=4; i--){ |
| 1795 | 1794 | if( aCollide[i].cnt==0 ) continue; |
| 1796 | 1795 | if( aCollide[i].cnt>200 ) break; |
| 1797 | - kk += aCollide[i].cnt; | |
| 1798 | 1796 | if( aCollide[i].cnt<25 ){ |
| 1799 | 1797 | @ <p>Collisions of length %d(i): |
| 1800 | 1798 | }else{ |
| 1801 | 1799 | @ <p>First 25 collisions of length %d(i): |
| 1802 | 1800 | } |
| 1803 | 1801 |
| --- 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 |
-4
| --- src/statrep.c | ||
| +++ src/statrep.c | ||
| @@ -344,11 +344,10 @@ | ||
| 344 | 344 | ** Implements the "byuser" view for /reports. |
| 345 | 345 | */ |
| 346 | 346 | static void stats_report_by_user(){ |
| 347 | 347 | Stmt query = empty_Stmt; |
| 348 | 348 | int nRowNumber = 0; /* current TR number */ |
| 349 | - int nEventTotal = 0; /* Total event count */ | |
| 350 | 349 | int rowClass = 0; /* counter for alternating |
| 351 | 350 | row colors */ |
| 352 | 351 | int nMaxEvents = 1; /* max number of events for |
| 353 | 352 | all rows. */ |
| 354 | 353 | stats_report_init_view(); |
| @@ -392,11 +391,10 @@ | ||
| 392 | 391 | ? (int)(100 * nCount / nMaxEvents) |
| 393 | 392 | : 0; |
| 394 | 393 | if(!nCount) continue /* arguable! Possible? */; |
| 395 | 394 | else if(!nSize) nSize = 1; |
| 396 | 395 | rowClass = ++nRowNumber % 2; |
| 397 | - nEventTotal += nCount; | |
| 398 | 396 | @ <tr class='row%d(rowClass)'> |
| 399 | 397 | @ <td> |
| 400 | 398 | @ <a href="?view=bymonth&user=%h(zUser)&type=%c(y)">%h(zUser)</a> |
| 401 | 399 | @ </td><td data-sortkey='%08x(-nCount)'>%d(nCount)</td> |
| 402 | 400 | @ <td> |
| @@ -475,11 +473,10 @@ | ||
| 475 | 473 | ** the report is restricted to events created by the named user account. |
| 476 | 474 | */ |
| 477 | 475 | static void stats_report_day_of_week(const char *zUserName){ |
| 478 | 476 | Stmt query = empty_Stmt; |
| 479 | 477 | int nRowNumber = 0; /* current TR number */ |
| 480 | - int nEventTotal = 0; /* Total event count */ | |
| 481 | 478 | int rowClass = 0; /* counter for alternating |
| 482 | 479 | row colors */ |
| 483 | 480 | int nMaxEvents = 1; /* max number of events for |
| 484 | 481 | all rows. */ |
| 485 | 482 | Blob userFilter = empty_blob; /* Optional user=johndoe query string */ |
| @@ -549,11 +546,10 @@ | ||
| 549 | 546 | ? (int)(100 * nCount / nMaxEvents) |
| 550 | 547 | : 0; |
| 551 | 548 | if(!nCount) continue /* arguable! Possible? */; |
| 552 | 549 | else if(!nSize) nSize = 1; |
| 553 | 550 | rowClass = ++nRowNumber % 2; |
| 554 | - nEventTotal += nCount; | |
| 555 | 551 | @<tr class='row%d(rowClass)'> |
| 556 | 552 | @ <td>%d(dayNum)</td> |
| 557 | 553 | @ <td>%s(daysOfWeek[dayNum])</td> |
| 558 | 554 | @ <td>%d(nCount)</td> |
| 559 | 555 | @ <td> |
| 560 | 556 |
| --- 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 @@ | ||
| 903 | 903 | ** On non-Windows systems, calls nice(2) with the given level. Errors |
| 904 | 904 | ** are ignored. On Windows this is a no-op. |
| 905 | 905 | */ |
| 906 | 906 | void fossil_nice(int level){ |
| 907 | 907 | #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*/ } | |
| 909 | 911 | #else |
| 910 | 912 | (void)level; |
| 911 | 913 | #endif |
| 912 | 914 | } |
| 913 | 915 | |
| 914 | 916 |
| --- 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 |