]> git.proxmox.com Git - mirror_qemu.git/commit
tpm.c: Don't try to put -1 in a variable of type TpmModel
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 29 Jul 2013 11:22:11 +0000 (12:22 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 29 Jul 2013 15:37:10 +0000 (10:37 -0500)
commit8cdd2e0abbf593a38a146d8dfc998754cefbc27a
tree8252d47bb077e7d7453b79ed99ec343643a517a9
parent125ee0ed9cad04307498ac2b7b0d51ad8a807360
tpm.c: Don't try to put -1 in a variable of type TpmModel

The TpmModel type is an enum (valid values 0 and 1), which means
the compiler can legitimately decide that comparisons like
'tpm_models[i] == -1' are never true. (For example it could
pick 'unsigned char' as its type for representing the enum.)

Avoid this issue by using TPM_MODEL_MAX to mark entries in
the tpm_models[] array which aren't filled in, instead of -1.

This silences a clang warning:

 tpm.c:43:27: error: comparison of constant -1 with expression of type
      'enum TpmModel' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
        if (tpm_models[i] == -1) {
            ~~~~~~~~~~~~~ ^  ~~

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1375096931-13842-1-git-send-email-peter.maydell@linaro.org
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
tpm.c