Skip to content
  • Peter Maydell's avatar
    tpm.c: Don't try to put -1 in a variable of type TpmModel · 8cdd2e0a
    Peter Maydell authored
    
    
    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: default avatarPeter Maydell <peter.maydell@linaro.org>
    Message-id: 1375096931-13842-1-git-send-email-peter.maydell@linaro.org
    Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
    8cdd2e0a