mini-os: tpm: fix array access in locality_enabled

gcc-4.3 fails to prove that array indices will remain positive. Add a
hint for the compiler and check the index value before using it.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
This commit is contained in:
Olaf Hering authored and Ian Campbell committed 2014-07-24 16:23:18 +01:00
1 parent 597eaa8db9
commit 52bdfeacbb
1 file changed
+1 -1
+1 -1
View File
@@ -611,7 +611,7 @@ s_time_t tpm_calc_ordinal_duration(struct tpm_chip *chip,
static int locality_enabled(struct tpm_chip* tpm, int l) {
return tpm->enabled_localities & (1 << l);
return l >= 0 && tpm->enabled_localities & (1 << l);
}
static int check_locality(struct tpm_chip* tpm, int l) {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.