From patchwork Fri Oct 16 17:48:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 55139 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id B99B922EAC for ; Fri, 16 Oct 2015 17:49:02 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf26835784lbc.1 for ; Fri, 16 Oct 2015 10:49:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=jLNHT1jEu23U8Tn+OvBRwgaGI74IYQ62JNViOtymjas=; b=IaWJmG7Pbp35guh3kO19iPn3/y2pD0ZBJNhMhC4CDmFSYlt/fe7P02Jn+vD0nYgd0Y yYahrPWTwq0dqOYL4M+48JDZPlZ/xyOk0sRzhc8CvS4d7ekjU5smh9g2PRq2GylcQwuH mhP11Wad6KIn+snm6qR7tAOSv15MSfr78tAptJFYTQgaBkYAKurkT2l9CXs3P5OyFm+z r2AUpuiDxq3h5hjrPd1aXbrc1HM3XKnL3akyk4/3QDOp8BwFeENz7zSLD4+Odm25LrO0 ZRrQqQvLWWYzFLGfhAt5BA639XNykDz1Crtn58ErSfihe7r/r4fDCl6wNNg0wOALaMHe EDTQ== X-Gm-Message-State: ALoCoQkUFTgh0OsQ03aIYjxM+PBBOnQoZnaOLGsOOn9BnIoaJIULtfw2PefWqdTVySgsMgUwzaqo X-Received: by 10.180.106.197 with SMTP id gw5mr1453784wib.7.1445017741650; Fri, 16 Oct 2015 10:49:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.19.100 with SMTP id j97ls348025lfi.50.gmail; Fri, 16 Oct 2015 10:49:01 -0700 (PDT) X-Received: by 10.25.21.83 with SMTP id l80mr6013862lfi.79.1445017741501; Fri, 16 Oct 2015 10:49:01 -0700 (PDT) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id r7si13625152lfe.1.2015.10.16.10.49.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 10:49:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lffv3 with SMTP id v3so83491937lff.0 for ; Fri, 16 Oct 2015 10:49:01 -0700 (PDT) X-Received: by 10.25.40.130 with SMTP id o124mr5723286lfo.41.1445017741358; Fri, 16 Oct 2015 10:49:01 -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.112.59.35 with SMTP id w3csp61185lbq; Fri, 16 Oct 2015 10:49:00 -0700 (PDT) X-Received: by 10.180.86.165 with SMTP id q5mr6393569wiz.27.1445017740733; Fri, 16 Oct 2015 10:49:00 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id oe6si6415250wic.41.2015.10.16.10.49.00 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 16 Oct 2015 10:49:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Zn97j-0003sP-2L; Fri, 16 Oct 2015 18:48:59 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, John Snow , qemu-block@nongnu.org Subject: [PATCH] hw/ide/ahci.c: Fix shift left into sign bit Date: Fri, 16 Oct 2015 18:48:59 +0100 Message-Id: <1445017739-14876-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mailfrom=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: , Avoid undefined behaviour from shifting left into the sign bit: hw/ide/ahci.c:551:36: runtime error: left shift of 255 by 24 places cannot be represented in type 'int' (Unfortunately C's promotion rules mean that in the expression "some_uint8_t_variable << 24" the LHS gets promoted to signed int before shifting.) Signed-off-by: Peter Maydell Reviewed-by: John Snow --- clang's undefined sanitizer produces a lot of copies of this warning during 'make check'... hw/ide/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 796be15..21f76ed 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -548,7 +548,7 @@ static void ahci_init_d2h(AHCIDevice *ad) ad->init_d2h_sent = true; /* We're emulating receiving the first Reg H2D Fis from the device; * Update the SIG register, but otherwise proceed as normal. */ - pr->sig = (ide_state->hcyl << 24) | + pr->sig = ((uint32_t)ide_state->hcyl << 24) | (ide_state->lcyl << 16) | (ide_state->sector << 8) | (ide_state->nsector & 0xFF);