Skip to content

Commit

Permalink
Fix two minor lint errors (cppcheck)
Browse files Browse the repository at this point in the history
Fix two minor errors reported by cppcheck:

In module/zfs/abd.c (abd_get_offset_impl), add non-NULL
assertion to prevent NULL dereference warning.

In module/zfs/arc.c (l2arc_write_buffers), change 'try'
variable to 'pass' to avoid C++ reserved word.

Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Colm Buckley <[email protected]>
Closes #11507
  • Loading branch information
colmbuckley authored Jan 23, 2021
1 parent 5aa69a5 commit 4a90d4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions module/zfs/abd.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ abd_get_offset_impl(abd_t *abd, abd_t *sabd, size_t off, size_t size)
abd = abd_get_offset_scatter(abd, sabd, off);
}

ASSERT3P(abd, !=, NULL);
abd->abd_size = size;
abd->abd_parent = sabd;
(void) zfs_refcount_add_many(&sabd->abd_children, abd->abd_size, abd);
Expand Down
8 changes: 4 additions & 4 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9080,17 +9080,17 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz)
/*
* Copy buffers for L2ARC writing.
*/
for (int try = 0; try < L2ARC_FEED_TYPES; try++) {
for (int pass = 0; pass < L2ARC_FEED_TYPES; pass++) {
/*
* If try == 1 or 3, we cache MRU metadata and data
* If pass == 1 or 3, we cache MRU metadata and data
* respectively.
*/
if (l2arc_mfuonly) {
if (try == 1 || try == 3)
if (pass == 1 || pass == 3)
continue;
}

multilist_sublist_t *mls = l2arc_sublist_lock(try);
multilist_sublist_t *mls = l2arc_sublist_lock(pass);
uint64_t passed_sz = 0;

VERIFY3P(mls, !=, NULL);
Expand Down

0 comments on commit 4a90d4d

Please sign in to comment.