core/unit: fix unit_add_target_dependencies() for units with no dependencies

For units without any dependencies, r needs to be initialized to 0.
Otherwise, the return value of unit_add_target_dependencies() is
unspecified.