[PATCH 5/5] ARM: OMAP2+: clean up some cppcheck warnings

2012-03-12 Thread Paul Walmsley
Resolve some warnings identified by cppcheck in arch/arm/mach-omap2:

[arch/arm/mach-omap2/usb-tusb6010.c:129]: (style) Checking if unsigned 
variable 'tmp' is less than zero.
[arch/arm/mach-omap2/prm_common.c:241]: (error) Possible null pointer 
dereference: irq_setup - otherwise it is redundant to check if irq_setup is 
null at line 247
[arch/arm/mach-omap2/pm34xx.c:790]: (style) Variable 'per_clkdm' is 
assigned a value that is never used
[arch/arm/mach-omap2/pm34xx.c:790]: (style) Variable 'core_clkdm' is 
assigned a value that is never used
[arch/arm/mach-omap2/pm24xx.c:185]: (style) Variable 'only_idle' is 
assigned a value that is never used
[arch/arm/mach-omap2/mux.c:254]: (error) Possible null pointer dereference: 
mux
[arch/arm/mach-omap2/mux.c:258]: (error) Possible null pointer dereference: 
mux
[arch/arm/mach-omap2/mcbsp.c:133]: (warning) scanf without field width 
limits can crash with huge input data
[arch/arm/mach-omap2/gpmc-onenand.c:178]: (style) Variable 'tick_ns' is 
assigned a value that is never used
[arch/arm/mach-omap2/gpio.c:43]: (warning) scanf without field width limits 
can crash with huge input data
[arch/arm/mach-omap2/gpio.c:56]: (error) Possible null pointer dereference: 
pdata - otherwise it is redundant to check if pdata is null at line 57
[arch/arm/mach-omap2/devices.c:45]: (style) Variable 'l' is assigned a 
value that is never used
[arch/arm/mach-omap2/board-am3517evm.c:134]: (style) Variable 'regval' is 
assigned a value that is never used

Some of them are pretty good catches, such the gpio.c:56 and
usb-tusb6010.c:129.

Signed-off-by: Paul Walmsley 
Cc: Felipe Balbi 
Cc: Tony Lindgren 
Cc: Kevin Hilman 
Cc: Peter Ujfalusi 
Cc: Jarkko Nikula 
Cc: Charulatha Varadarajan 
---
 arch/arm/mach-omap2/board-am3517evm.c |6 +-
 arch/arm/mach-omap2/board-omap3evm.c  |8 
 arch/arm/mach-omap2/devices.c |3 +--
 arch/arm/mach-omap2/gpio.c|4 ++--
 arch/arm/mach-omap2/gpmc-onenand.c|3 +--
 arch/arm/mach-omap2/mcbsp.c   |2 +-
 arch/arm/mach-omap2/mux.c |2 +-
 arch/arm/mach-omap2/pm24xx.c  |3 ---
 arch/arm/mach-omap2/pm34xx.c  |4 +---
 arch/arm/mach-omap2/prm_common.c  |4 +++-
 arch/arm/mach-omap2/usb-tusb6010.c|2 +-
 11 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/arch/arm/mach-omap2/board-am3517evm.c 
b/arch/arm/mach-omap2/board-am3517evm.c
index 4b1cfe3..24b1f9a 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -150,13 +150,9 @@ static void am3517_evm_ethernet_init(struct 
emac_platform_data *pdata)
regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
regval = regval & (~(AM35XX_CPGMACSS_SW_RST));
omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
-   regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
-
-   return ;
+   omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
 }
 
-
-
 #define LCD_PANEL_PWR  176
 #define LCD_PANEL_BKLIGHT_PWR  182
 #define LCD_PANEL_PWM  181
diff --git a/arch/arm/mach-omap2/board-omap3evm.c 
b/arch/arm/mach-omap2/board-omap3evm.c
index c877236..becf41d 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -634,12 +634,12 @@ static void __init omap3_evm_wl12xx_init(void)
 
 static void __init omap3_evm_init(void)
 {
+   static struct omap_board_mux *obm;
+
omap3_evm_get_revision();
 
-   if (cpu_is_omap3630())
-   omap3_mux_init(omap36x_board_mux, OMAP_PACKAGE_CBB);
-   else
-   omap3_mux_init(omap35x_board_mux, OMAP_PACKAGE_CBB);
+   obm = (cpu_is_omap3630()) ? omap36x_board_mux : omap35x_board_mux;
+   omap3_mux_init(obm, OMAP_PACKAGE_CBB);
 
omap_board_config = omap3_evm_config;
omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 283d11e..b52cd16 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -42,7 +42,6 @@
 
 static int __init omap3_l3_init(void)
 {
-   int l;
struct omap_hwmod *oh;
struct platform_device *pdev;
char oh_name[L3_MODULES_MAX_LEN];
@@ -54,7 +53,7 @@ static int __init omap3_l3_init(void)
if (!(cpu_is_omap34xx()))
return -ENODEV;
 
-   l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
+   snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
 
oh = omap_hwmod_lookup(oh_name);
 
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 8cbfbc2..f64fcb2 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -40,7 +40,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void 
*unused)
 * not change. If changed, make corresponding change here
 * or make use of static variable mechanism to handle this.

Re: [PATCH 5/5] ARM: OMAP2+: clean up some cppcheck warnings

2012-03-13 Thread Jarkko Nikula
On 03/13/2012 12:43 AM, Paul Walmsley wrote:
> Resolve some warnings identified by cppcheck in arch/arm/mach-omap2:
...
> [arch/arm/mach-omap2/mcbsp.c:133]: (warning) scanf without field width 
> limits can crash with huge input data
...
> diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
> index fb4bcf8..efe59c7 100644

> --- a/arch/arm/mach-omap2/mcbsp.c
> +++ b/arch/arm/mach-omap2/mcbsp.c
> @@ -130,7 +130,7 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void 
> *unused)
>   struct omap_mcbsp_platform_data *pdata = NULL;
>   struct platform_device *pdev;
>  
> - sscanf(oh->name, "mcbsp%d", &id);
> + sscanf(oh->name, "mcbsp%1d", &id);
>  
Correct if I'm wrong but is this a false alarm? Can %d scan more than
sizeof(int)?

Anyway this shouldn't be fatal issue since name comes from kernel
omap_hwmod data, i.e. only developer can hit it.

Peter: worth to check and possible add this Paul's fix to your mcbsp
change set.

-- 
Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/5] ARM: OMAP2+: clean up some cppcheck warnings

2012-03-13 Thread Paul Walmsley
On Tue, 13 Mar 2012, Jarkko Nikula wrote:

> On 03/13/2012 12:43 AM, Paul Walmsley wrote:
> > Resolve some warnings identified by cppcheck in arch/arm/mach-omap2:
> ...
> > [arch/arm/mach-omap2/mcbsp.c:133]: (warning) scanf without field width 
> > limits can crash with huge input data
> ...
> > diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
> > index fb4bcf8..efe59c7 100644
> 
> > --- a/arch/arm/mach-omap2/mcbsp.c
> > +++ b/arch/arm/mach-omap2/mcbsp.c
> > @@ -130,7 +130,7 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void 
> > *unused)
> > struct omap_mcbsp_platform_data *pdata = NULL;
> > struct platform_device *pdev;
> >  
> > -   sscanf(oh->name, "mcbsp%d", &id);
> > +   sscanf(oh->name, "mcbsp%1d", &id);
> >  
> Correct if I'm wrong but is this a false alarm? Can %d scan more than
> sizeof(int)?
> 
> Anyway this shouldn't be fatal issue since name comes from kernel
> omap_hwmod data, i.e. only developer can hit it.

Yes, I wasn't too worried about this one.  At the time, I didn't audit the 
kernel sscanf(), so I wasn't sure what its behavior was here. Glancing at 
that code now, it seems to ignore the field width for %d anyway.  So this 
is probably a pointless change that can be dropped from the patch.

Thanks for the review.


- Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html