Fix cppcheck issues
This MR consists of the cppcheck-related former parts of !5 (merged), split out to make the whole more manageable.
It is not intended that this MR be merged until !5 (merged) and !19 (merged) have been merged, so you will see their commits in the history of this branch. This avoids having to rebase this MR multiple times. Please direct any comments relating to these commits to the relevant MR, not this one.
If you examine the branch where it diverges from the earlier MRs, what you should see is a series of commits, which for the most part each focus on one of the issues identified by cppcheck. This should hopefully make reviewing them easier to digest, provided you avoid looking at GitLab's view of the changes due to the MR as a whole!
Note that this is still not expected to result in a clean sweep of CI passes until Support/CI_Source!10 (merged) and Support/CI_Source!13 (closed) are merged.