From patchwork Mon Jul 29 11:22:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 18628 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 824E62395F for ; Mon, 29 Jul 2013 11:22:15 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id ht10sf3524801vcb.1 for ; Mon, 29 Jul 2013 04:22:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=mSK8nKkk1KncLIljf8nRpteuDuW1F749E6xFBCNQta0=; b=XayTWBQRE4NDaBYev5DFnggDCoNGpwIx0+Uw+3FDYe0sYGGF5vDRVeqHHJIEDsLx7n aTjoxRQir6WC89GqIHb34f244IVSNCV4FRAueM96zo1R4AFDcLJV223dZbF3YmpFotbZ HWWJ3+ZQS+lC6WM6qjGO9m4JL0Uaa7LzADnH6M+8CTA4eGaEriQYW5S+fTQm+n3LH1oi BoeHEcsozbH51OVJthpKNNKihOj1gSv1X/U0NVhfH69yj91wVReLcJvoyhbljMSuII6x EktPe0XKQhatK05gObapXBHxylzFf8nqN+LKh8e35JGceH5mdMswg4k1emH5m7VbniCK eXnA== X-Received: by 10.236.190.72 with SMTP id d48mr7535035yhn.0.1375096934710; Mon, 29 Jul 2013 04:22:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.12.233 with SMTP id b9ls1877882qec.14.gmail; Mon, 29 Jul 2013 04:22:14 -0700 (PDT) X-Received: by 10.58.54.70 with SMTP id h6mr25541065vep.36.1375096934578; Mon, 29 Jul 2013 04:22:14 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id zt2si17524814vec.36.2013.07.29.04.22.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Jul 2013 04:22:14 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id ij15so1953860vcb.30 for ; Mon, 29 Jul 2013 04:22:14 -0700 (PDT) X-Received: by 10.58.211.227 with SMTP id nf3mr25801597vec.20.1375096934467; Mon, 29 Jul 2013 04:22:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.11.8 with SMTP id pc8csp110964vcb; Mon, 29 Jul 2013 04:22:13 -0700 (PDT) X-Received: by 10.180.38.45 with SMTP id d13mr6741369wik.62.1375096933342; Mon, 29 Jul 2013 04:22:13 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id bg10si6274085wjc.155.2013.07.29.04.22.12 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 29 Jul 2013 04:22:13 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1V3lWl-0003bj-GU; Mon, 29 Jul 2013 12:22:11 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Berger , Anthony Liguori Subject: [PATCH for-1.6?] tpm.c: Don't try to put -1 in a variable of type TpmModel Date: Mon, 29 Jul 2013 12:22:11 +0100 Message-Id: <1375096931-13842-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQkypsxBPeGzhBMYveekMUvTFGJMH7X/CebgPPsGtu1WXVZSM72x2O9BYhf6kA1GF5Lccae4 X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- Disclaimer: I have compiled this, and it's a pretty safe looking change, but I haven't tested it... tpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tpm.c b/tpm.c index f13c9bc..d68d69f 100644 --- a/tpm.c +++ b/tpm.c @@ -32,7 +32,7 @@ static TPMDriverOps const *be_drivers[TPM_MAX_DRIVERS] = { }; static enum TpmModel tpm_models[TPM_MAX_MODELS] = { - -1, + TPM_MODEL_MAX, }; int tpm_register_model(enum TpmModel model) @@ -40,7 +40,7 @@ int tpm_register_model(enum TpmModel model) int i; for (i = 0; i < TPM_MAX_MODELS; i++) { - if (tpm_models[i] == -1) { + if (tpm_models[i] == TPM_MODEL_MAX) { tpm_models[i] = model; return 0; }