[CLEANUP] Ensure all variables are set before usage

This also applies for return values of functions. These are corrected
too if necessary.

Furthermore, some code style updates are done for better readability.

This patch contains no functional changes.

Resolves: #59775
Releases: 6.3, 6.2
Change-Id: I1e26e0516d79324244948caf091cd836d5f8d3c6
Reviewed-on: https://review.typo3.org/31380
Reviewed-by: Fabien Udriot
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn