cppcheck: fix variable reassigned before the old value has been used

Change-Id: I866eaf946d4cd8eaa8e4b8799ddac5e0d5dc59bb