Pre instead of post increment a variable.

Issue found by cppcheck.
Pre instead of post increment a variable.

Issue found by cppcheck.
Pre instead of post increment a variable.

Issue found by cppcheck.
Pre instead of post increment a variable.

Issue found by cppcheck.
Remove a variable which is only assigned.

Issue found by cppcheck.
Remove a variable which is only assigned.

Issue found by cppcheck.
Remove a variable which is only assigned.

Issue found by cppcheck.
Remove a variable which is only assigned.

Issue found by cppcheck.
Remove a variable which is only assigned.

Issue found by cppcheck.
Limit variable scope.

Also avoid shadowing the variable res.

Issue found by cppcheck.
Remove an unneeded temporary variable.

Issue found by cppcheck.