coverity#1242895 Untrusted loop bound

Change-Id: If01f0edecca8988087386507717ea8222058bab8
coverity#1242775 Use of untrusted scalar value

Change-Id: Iaaf92c4be9b41c5824a1b1474fbce19a1afa49ae
silence coverity#1242911 Untrusted loop bound

Change-Id: Ifab75371cbedd26d510f162efe2c9247e37893ed
coverity#1242875 Untrusted pointer write

Change-Id: I197a67320bd6cd8f0e6735b8cd24deebcdf190f1
fix typo, thanks to Matteo

Change-Id: I6fd3f69cc56672fe2639ee575f9ed0cdf45490bd