Fix some cppcheck SCA issues v2

Fixed issues:
- remove unused variable(s)
- fix possible NULL pointer dereference
- remove not needed code
- reduce scope of local variable(s)

----
v2: 
- adopted comments from pull request #287
- dropped fsx patches
- fix some kernel related issues