Re: [PATCH v2]ipmi:ipmi_si_intf.c Fix warning: variable 'addr_space'set but not used

From: Justin P. Mattock
Date: Tue Jul 06 2010 - 16:18:22 EST


On 07/06/2010 01:14 PM, Sergey V. wrote:
On Tuesday 06 of July 2010 22:30:00 Justin P. Mattock wrote:

Hello Justin.

[...]
@@ -2021,10 +2020,6 @@ static __devinit int try_init_spmi(struct SPMITable
*spmi)
}

if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
- addr_space = IPMI_MEM_ADDR_SPACE;
- else
- addr_space = IPMI_IO_ADDR_SPACE;
-
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
printk(KERN_ERR PFX "Could not allocate SI data (3)\n");

This looks like after applying this patch 'info = ...' will be part of
if statement (without indent before 'info = ...')

if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
info = kzalloc(sizeof(*info), GFP_KERNEL);

It's correct?

Thanks


the original patch I dont think this is correct. a bit confusing with
the if(!info) at the bottom of this.
here's an updated version if it looks to be correct I'll resend if not
I'll redu:


---
drivers/char/ipmi/ipmi_si_intf.c | 7 -------
1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si_intf.c
b/drivers/char/ipmi/ipmi_si_intf.c
index 094bdc3..ef03ecd 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2013,19 +2013,12 @@ struct SPMITable {
static __devinit int try_init_spmi(struct SPMITable *spmi)
{
struct smi_info *info;
- u8 addr_space;

if (spmi->IPMIlegacy != 1) {
printk(KERN_INFO PFX "Bad SPMI legacy %d\n", spmi->IPMIlegacy);
return -ENODEV;
}

- if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
- addr_space = IPMI_MEM_ADDR_SPACE;
- else
- addr_space = IPMI_IO_ADDR_SPACE;
-
- info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
printk(KERN_ERR PFX "Could not allocate SI data (3)\n");
return -ENOMEM;
-- 1.7.1.rc1.21.gf3bd6

Thanks for the info on this..

Justin P. Mattock


Sorry, but I think that new patch is not correct.

Why do you delete this row "info = kzalloc(sizeof(*info), GFP_KERNEL)"?
There is the only one unused variable `addr_space`, so I think it should
be removed, that's all.

The following code is correct and not need to be changed:

info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
printk(KERN_ERR PFX "Could not allocate SI data (3)\n");

Please see below my patch.
Thanks.

---
Fix compile warning
drivers/char/ipmi/ipmi_si_intf.c: In function 'try_init_spmi':
drivers/char/ipmi/ipmi_si_intf.c:2016:8: warning: variable 'addr_space' set but
not used

Signed-off-by: Sergey V.<sftp.mtuci@xxxxxxxxx>
---
drivers/char/ipmi/ipmi_si_intf.c | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_si_intf.c
b/drivers/char/ipmi/ipmi_si_intf.c
index 094bdc3..1f5f025 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2013,18 +2013,12 @@ struct SPMITable {
static __devinit int try_init_spmi(struct SPMITable *spmi)
{
struct smi_info *info;
- u8 addr_space;

if (spmi->IPMIlegacy != 1) {
printk(KERN_INFO PFX "Bad SPMI legacy %d\n", spmi->IPMIlegacy);
return -ENODEV;
}

- if (spmi->addr.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
- addr_space = IPMI_MEM_ADDR_SPACE;
- else
- addr_space = IPMI_IO_ADDR_SPACE;
-
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
printk(KERN_ERR PFX "Could not allocate SI data (3)\n");


well if everybody agrees with your change then all good...

Justin P. Mattock
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/