Avoid undefined left shift of negative value

Change-Id: I6496a16c4d6791af43a67dae57b9ee218c3444fe