Commit 3b8ebc9
committed
Cleanup: Address Clang's static analyzer's unused code complaints
These were categorized as the following:
* Dead assignment 23
* Dead increment 4
* Dead initialization 6
* Dead nested assignment 18
Most of these are harmless, but since actual issues can hide among them,
we correct them.
That said, there were a few return values that were being ignored that
appeared to merit some correction:
* `destroy_callback()` in `cmd/zfs/zfs_main.c` ignored the error from
`destroy_batched()`. We handle it by returning -1 if there is an
error.
* `zfs_do_upgrade()` in `cmd/zfs/zfs_main.c` ignored the error from
`zfs_for_each()`. We handle it by doing a binary OR of the error
value from the subsequent `zfs_for_each()` call to the existing
value. This is how errors are mostly handled inside `zfs_for_each()`.
* `get_zap_prop()` in `module/zfs/zcp_get.c` ignored the
`dsl_prop_get_ds()` when the property is not of type string. We
return an error if it does. There is a small concern that the
`zfs_get_temporary_prop()` call would handle things, but in the case
that it does not, we would be pushing an uninitialized numval onto
the lua stack. It is expected that `dsl_prop_get_ds()` will succeed
anytime that `zfs_get_temporary_prop()` does, so that not giving it a
chance to fix things is not a problem.
* `draid_merge_impl()` in `tests/zfs-tests/cmd/draid.c` used
`nvlist_add_nvlist()` twice in ways in which errors are expected to
be impossible, so we switch to `fnvlist_add_nvlist()`.
A few notable ones did not merit use of the return value, so we
suppressed it with `(void)`:
* `write_free_diffs()` in `lib/libzfs/libzfs_diff.c` ignored the error
value from `describe_free()`. A look through the commit history
revealed that this was intentional.
* `arc_evict_hdr()` in `module/zfs/arc.c` did not need to use the
returned handle from `arc_hdr_realloc()` because it is already
referenced in lists.
* `spa_vdev_detach()` in `module/zfs/spa.c` has a comment explicitly
saying not to use the error from `vdev_label_init()` because whatever
causes the error could be the reason why a detach is being done.
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>1 parent 67395be commit 3b8ebc9
File tree
32 files changed
+45
-73
lines changed- cmd
- raidz_test
- zfs
- lib
- libefi
- libzfs
- libzutil/os/linux
- module
- icp/algs
- blake3
- modes
- lua
- os
- freebsd/zfs
- linux/zfs
- zfs
- tests/zfs-tests/cmd
32 files changed
+45
-73
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | 149 | | |
152 | 150 | | |
153 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1453 | 1453 | | |
1454 | 1454 | | |
1455 | 1455 | | |
1456 | | - | |
| 1456 | + | |
1457 | 1457 | | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
1458 | 1463 | | |
1459 | 1464 | | |
1460 | 1465 | | |
| |||
2576 | 2581 | | |
2577 | 2582 | | |
2578 | 2583 | | |
2579 | | - | |
| 2584 | + | |
2580 | 2585 | | |
2581 | 2586 | | |
2582 | 2587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
427 | 426 | | |
428 | 427 | | |
429 | 428 | | |
| |||
565 | 564 | | |
566 | 565 | | |
567 | 566 | | |
568 | | - | |
569 | 567 | | |
570 | 568 | | |
571 | | - | |
| 569 | + | |
572 | 570 | | |
573 | 571 | | |
574 | 572 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2006 | 2006 | | |
2007 | 2007 | | |
2008 | 2008 | | |
2009 | | - | |
| 2009 | + | |
2010 | 2010 | | |
2011 | 2011 | | |
2012 | 2012 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2214 | 2214 | | |
2215 | 2215 | | |
2216 | 2216 | | |
2217 | | - | |
2218 | 2217 | | |
2219 | 2218 | | |
2220 | 2219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2117 | 2117 | | |
2118 | 2118 | | |
2119 | 2119 | | |
2120 | | - | |
| 2120 | + | |
2121 | 2121 | | |
2122 | | - | |
| 2122 | + | |
2123 | 2123 | | |
2124 | 2124 | | |
2125 | 2125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1249 | 1249 | | |
1250 | 1250 | | |
1251 | 1251 | | |
1252 | | - | |
| 1252 | + | |
1253 | 1253 | | |
1254 | 1254 | | |
1255 | 1255 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
432 | 431 | | |
433 | 432 | | |
434 | 433 | | |
| |||
450 | 449 | | |
451 | 450 | | |
452 | 451 | | |
453 | | - | |
| 452 | + | |
454 | 453 | | |
455 | 454 | | |
456 | 455 | | |
| |||
479 | 478 | | |
480 | 479 | | |
481 | 480 | | |
482 | | - | |
483 | | - | |
| 481 | + | |
484 | 482 | | |
485 | 483 | | |
486 | 484 | | |
| |||
499 | 497 | | |
500 | 498 | | |
501 | 499 | | |
502 | | - | |
| 500 | + | |
503 | 501 | | |
504 | 502 | | |
505 | 503 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
193 | | - | |
194 | | - | |
| 192 | + | |
195 | 193 | | |
196 | 194 | | |
197 | 195 | | |
| |||
0 commit comments