[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/31020
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Markus Klein
Tested-by: Markus Klein