fdo#39440 sc: reduce scope of local variables

This addresses some cppcheck warnings.

Change-Id: I2eaf9a6792ca2c06a005385ec45c08f1292cba23