Skip to content

Commit

Permalink
Suppress Clang Static Analyzer warning in dsl_dir_rename_sync()
Browse files Browse the repository at this point in the history
Clang's static analyzer reports that if we try to rename a root dataset
in `dsl_dir_rename_sync()`, we will have a NULL pointer passed to
strlcpy(). This is impossible because `dsl_dir_rename_check()` will
prevent us from doing this. We add an assertion to silence this warning.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs#14575
  • Loading branch information
ryao authored and behlendorf committed Mar 8, 2023
1 parent 17443e0 commit 45c4463
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions module/zfs/dsl_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 2125,8 @@ dsl_dir_rename_sync(void *arg, dmu_tx_t *tx)
VERIFY0(dsl_dir_hold(dp, ddra->ddra_newname, FTAG, &newparent,
&mynewname));

ASSERT3P(mynewname, !=, NULL);

/* Log this before we change the name. */
spa_history_log_internal_dd(dd, "rename", tx,
"-> %s", ddra->ddra_newname);
Expand Down

0 comments on commit 45c4463

Please sign in to comment.