Patchwork [U-Boot,2/7] CFI: fix warning: variable ... set but not used

login
register
mail settings
Submitter Wolfgang Denk
Date Oct. 5, 2011, 9:17 p.m.
Message ID <1317849453-8216-2-git-send-email-wd@denx.de>
Download mbox | patch
Permalink /patch/117920/
State Accepted
Headers show

Comments

Wolfgang Denk - Oct. 5, 2011, 9:17 p.m.
Fix:
cfi_mtd.c: In function 'cfi_mtd_init':
cfi_mtd.c:226:19: warning: variable 'mtd_list' set but not used [-Wunused-but-set-variable]
cfi_mtd.c: In function 'cfi_mtd_init':
cfi_mtd.c:226:19: warning: variable 'mtd_list' set but not used [-Wunused-but-set-variable]

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Stefan Roese <sr@denx.de>
---
 common/cmd_mtdparts.c |    9 +++++++--
 drivers/mtd/cfi_mtd.c |    4 ++++
 2 files changed, 11 insertions(+), 2 deletions(-)
Stefan Roese - Oct. 6, 2011, 5:54 a.m.
Hi Wolfgang,

On Wednesday 05 October 2011 23:17:28 Wolfgang Denk wrote:
> Fix:
> cfi_mtd.c: In function 'cfi_mtd_init':
> cfi_mtd.c:226:19: warning: variable 'mtd_list' set but not used
> [-Wunused-but-set-variable] cfi_mtd.c: In function 'cfi_mtd_init':
> cfi_mtd.c:226:19: warning: variable 'mtd_list' set but not used
> [-Wunused-but-set-variable]
>
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Cc: Stefan Roese <sr@denx.de>

Acked-by: Stefan Roese <sr@denx.de>

Feel free to apply directly if this is easier for you.

Thanks,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de
Wolfgang Denk - Oct. 6, 2011, 7:55 a.m.
Dear Stefan Roese,

In message <201110060754.18167.sr@denx.de> you wrote:
> 
> Acked-by: Stefan Roese <sr@denx.de>
> 
> Feel free to apply directly if this is easier for you.

Thanks, but actually the patch is incomplete; there is another similar
place that needs fixing, too.

Will send a v2 soon.

Best regards,

Wolfgang Denk
Wolfgang Denk - Oct. 9, 2011, 8:41 p.m.
Dear Wolfgang Denk,

In message <1317849453-8216-2-git-send-email-wd@denx.de> you wrote:
> Fix:
> cfi_mtd.c: In function 'cfi_mtd_init':
> cfi_mtd.c:226:19: warning: variable 'mtd_list' set but not used [-Wunused-but-set-variable]
> cfi_mtd.c: In function 'cfi_mtd_init':
> cfi_mtd.c:226:19: warning: variable 'mtd_list' set but not used [-Wunused-but-set-variable]
> 
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> Cc: Stefan Roese <sr@denx.de>
> ---
>  common/cmd_mtdparts.c |    9 +++++++--
>  drivers/mtd/cfi_mtd.c |    4 ++++
>  2 files changed, 11 insertions(+), 2 deletions(-)

Applied (with changes to fix the other issue, too).

Best regards,

Wolfgang Denk

Patch

diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 5481c88..2c2e4e0 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -838,7 +838,10 @@  static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_
 	struct mtdids *id;
 	const char *mtd_id;
 	unsigned int mtd_id_len;
-	const char *p, *pend;
+	const char *p;
+#ifdef DEBUG
+	const char *pend;
+#endif
 	LIST_HEAD(tmp_list);
 	struct list_head *entry, *n;
 	u16 num_parts;
@@ -868,10 +871,12 @@  static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_
 		return 1;
 	}
 
+#ifdef DEBUG
+	pend = strchr(p, ';');
+#endif
 	debug("dev type = %d (%s), dev num = %d, mtd-id = %s\n",
 			id->type, MTD_DEV_TYPE(id->type),
 			id->num, id->mtd_id);
-	pend = strchr(p, ';');
 	debug("parsing partitions %.*s\n", (pend ? pend - p : strlen(p)), p);
 
 
diff --git a/drivers/mtd/cfi_mtd.c b/drivers/mtd/cfi_mtd.c
index cbcc165..7796c4c 100644
--- a/drivers/mtd/cfi_mtd.c
+++ b/drivers/mtd/cfi_mtd.c
@@ -223,7 +223,9 @@  int cfi_mtd_init(void)
 	flash_info_t *fi;
 	int error, i;
 	int devices_found = 0;
+#ifdef CONFIG_MTD_CONCAT
 	struct mtd_info *mtd_list[CONFIG_SYS_MAX_FLASH_BANKS];
+#endif
 
 	for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
 		fi = &flash_info[i];
@@ -253,7 +255,9 @@  int cfi_mtd_init(void)
 		if (add_mtd_device(mtd))
 			return -ENOMEM;
 
+#ifdef CONFIG_MTD_CONCAT
 		mtd_list[devices_found++] = mtd;
+#endif
 	}
 
 #ifdef CONFIG_MTD_CONCAT