From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mcf: Fix cppcheck errors about uninitialized variables
Date: Fri, 14 Nov 2014 13:47:33 +0100 [thread overview]
Message-ID: <20141114134733.01c82023@lilith> (raw)
In-Reply-To: <1415948172-41691-1-git-send-email-b18965@freescale.com>
Hello Alison,
On Fri, 14 Nov 2014 14:56:12 +0800, Alison Wang <b18965@freescale.com>
wrote:
> This patch will initialize the variables to fix the cppcheck errors as
> follows.
>
> [arch/m68k/cpu/mcf5227x/speed.c:89]: (error) Uninitialized variable: bootmode
> [arch/m68k/cpu/mcf532x/speed.c:248]: (error) Uninitialized variable: fout
> [arch/m68k/cpu/mcf5445x/speed.c:194]: (error) Uninitialized variable: bootmode
>
> Signed-off-by: Alison Wang <alison.wang@freescale.com>
> ---
> arch/m68k/cpu/mcf5227x/speed.c | 2 +-
> arch/m68k/cpu/mcf532x/speed.c | 3 ++-
> arch/m68k/cpu/mcf5445x/speed.c | 2 +-
> 3 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/arch/m68k/cpu/mcf5227x/speed.c b/arch/m68k/cpu/mcf5227x/speed.c
> index 44de4a6..e991cd1 100644
> --- a/arch/m68k/cpu/mcf5227x/speed.c
> +++ b/arch/m68k/cpu/mcf5227x/speed.c
> @@ -74,7 +74,7 @@ int get_clocks(void)
> ccm_t *ccm = (ccm_t *)MMAP_CCM;
> pll_t *pll = (pll_t *)MMAP_PLL;
> int vco, temp, pcrvalue, pfdr;
> - u8 bootmode;
> + u8 bootmode = 0;
If you set bootmode to the default 0 value at declaration, then the code
that follows in the source file can be simplified:
u8 bootmode = 0;
---8<---
pcrvalue = in_be32(&pll->pcr) & 0xFF0F0FFF;
pfdr = pcrvalue >> 24;
if (pfdr == 0x1E)
bootmode = 0; /* Normal Mode */
---8<---
The part between scissors is useless now, and in turn, pfdr becomes unneeded.
> pcrvalue = in_be32(&pll->pcr) & 0xFF0F0FFF;
> pfdr = pcrvalue >> 24;
> diff --git a/arch/m68k/cpu/mcf532x/speed.c b/arch/m68k/cpu/mcf532x/speed.c
> index a440bbb..0495b16 100644
> --- a/arch/m68k/cpu/mcf532x/speed.c
> +++ b/arch/m68k/cpu/mcf532x/speed.c
> @@ -143,7 +143,8 @@ int clock_pll(int fsys, int flags)
> #endif
> sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
> pll_t *pll = (pll_t *)(MMAP_PLL);
> - int fref, temp, fout, mfd;
> + int fref, temp, mfd;
> + int fout = 0;
> u32 i;
(haven't checked if similar reductions can be done)
> fref = FREF;
> diff --git a/arch/m68k/cpu/mcf5445x/speed.c b/arch/m68k/cpu/mcf5445x/speed.c
> index 4e363a4..a166dcc 100644
> --- a/arch/m68k/cpu/mcf5445x/speed.c
> +++ b/arch/m68k/cpu/mcf5445x/speed.c
> @@ -141,7 +141,7 @@ void setup_5445x_clocks(void)
> #ifdef CONFIG_M54455EVB
> u8 *cpld = (u8 *)(CONFIG_SYS_CS2_BASE + 3);
> #endif
> - u8 bootmode;
> + u8 bootmode = 0;
(ditto)
> /* To determine PCI is present or not */
> if (((in_be16(&ccm->ccr) & CCM_CCR_360_FBCONFIG_MASK) == 0x00e0) ||
> --
> 2.1.0.27.g96db324
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Amicalement,
--
Albert.
next prev parent reply other threads:[~2014-11-14 12:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-14 6:56 [U-Boot] [PATCH] mcf: Fix cppcheck errors about uninitialized variables Alison Wang
2014-11-14 12:47 ` Albert ARIBAUD [this message]
2014-11-14 13:23 ` Wolfgang Denk
2014-11-18 14:17 ` Tom Rini
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=20141114134733.01c82023@lilith \
--to=albert.u.boot@aribaud.net \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.