qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>,
	qemu-ppc@nongnu.org, BALATON Zoltan <balaton@eik.bme.hu>
Subject: Re: [Qemu-devel] [PATCH for-3.1] hw/ppc/ppc440_uc: Remove dead code in sdram_size()
Date: Wed, 7 Nov 2018 15:24:45 +1100	[thread overview]
Message-ID: <20181107042445.GB5575@umbus.fritz.box> (raw)
In-Reply-To: <20181030170353.7447-1-peter.maydell@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 1526 bytes --]

On Tue, Oct 30, 2018 at 05:03:53PM +0000, Peter Maydell wrote:
> Coverity points out in CID 1390588 that the test for sh == 0
> in sdram_size() can never fire, because we calculate sh with
>     sh = 1024 - ((bcr >> 6) & 0x3ff);
> which must result in a value between 1 and 1024 inclusive.
> 
> Without the relevant manual for the SoC, we're not completely
> sure of the correct behaviour here, but we can remove the
> dead code without changing how QEMU currently behaves.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Applied to ppc-for-3.1, thanks.

> ---
> We had a discussion about this coverity error a while back:
> https://lists.nongnu.org/archive/html/qemu-devel/2018-04/msg05187.html
> I'd just like to squash the Coverity warning, I think.
> 
>  hw/ppc/ppc440_uc.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c
> index 09ccda548f3..9360f781cef 100644
> --- a/hw/ppc/ppc440_uc.c
> +++ b/hw/ppc/ppc440_uc.c
> @@ -559,11 +559,7 @@ static target_ulong sdram_size(uint32_t bcr)
>      int sh;
>  
>      sh = 1024 - ((bcr >> 6) & 0x3ff);
> -    if (sh == 0) {
> -        size = -1;
> -    } else {
> -        size = 8 * MiB * sh;
> -    }
> +    size = 8 * MiB * sh;
>  
>      return size;
>  }

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2018-11-07  4:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 17:03 [Qemu-devel] [PATCH for-3.1] hw/ppc/ppc440_uc: Remove dead code in sdram_size() Peter Maydell
2018-10-30 22:40 ` BALATON Zoltan
2018-10-31 13:43 ` [Qemu-devel] [Qemu-ppc] " Laurent Vivier
2018-11-07  4:24 ` David Gibson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181107042445.GB5575@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=balaton@eik.bme.hu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).