If the source file is a directory and the target file exists, I don't think (newparent == 0) will happen.
Even if this case happens, dp represents the target directory, not the parent of the target directory.
The above conclusion is based on the test results of FreeBSD-13.0, I don't know whether it is correct.
I would be very grateful if someone could help answer this question!