public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] MTD: make mtd->name const
@ 2006-04-23 19:34 Martin Waitz
  2006-04-24  7:24 ` Jörn Engel
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Waitz @ 2006-04-23 19:34 UTC (permalink / raw)
  To: linux-mtd

mtd->name is never used read-write and often holds a pointer to constant data.

Signed-off-by: Martin Waitz <tali@admingilde.org>

---

 drivers/mtd/cmdlinepart.c       |    2 +-
 drivers/mtd/devices/block2mtd.c |   10 +++++-----
 include/linux/mtd/mtd.h         |    2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

94152d03bf8d7a28519a8e7f6bf1b53c30664f8d
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index a7a7bfe..615ae4d 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -300,7 +300,7 @@ static int parse_cmdline_partitions(stru
 	unsigned long offset;
 	int i;
 	struct cmdline_mtd_partition *part;
-	char *mtd_id = master->name;
+	const char *mtd_id = master->name;
 
 	if(!cmdline)
 		return -EINVAL;
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 4160b83..adb0ae8 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -289,6 +289,7 @@ static struct block2mtd_dev *add_device(
 {
 	struct block_device *bdev;
 	struct block2mtd_dev *dev;
+	char * name;
 
 	if (!devname)
 		return NULL;
@@ -315,13 +316,12 @@ static struct block2mtd_dev *add_device(
 
 	/* Setup the MTD structure */
 	/* make the name contain the block device in */
-	dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname),
-			GFP_KERNEL);
-	if (!dev->mtd.name)
+	name = kmalloc(sizeof("block2mtd: ") + strlen(devname), GFP_KERNEL);
+	if (!name)
 		goto devinit_err;
 
-	sprintf(dev->mtd.name, "block2mtd: %s", devname);
-
+	sprintf(name, "block2mtd: %s", devname);
+	dev->mtd.name = name;
 	dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
 	dev->mtd.erasesize = erase_size;
 	dev->mtd.type = MTD_RAM;
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index b6f2fda..886f481 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -84,7 +84,7 @@ #define MTD_PROGREGION_CTRLMODE_VALID(mt
 #define MTD_PROGREGION_CTRLMODE_INVALID(mtd)  (mtd)->ecctype
 
 	// Kernel-only stuff starts here.
-	char *name;
+	const char *name;
 	int index;
 
 	// oobinfo is a nand_oobinfo structure, which can be set by iotcl (MEMSETOOBINFO)
-- 
1.3.0.gc5417

-- 
Martin Waitz

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MTD: make mtd->name const
  2006-04-23 19:34 [PATCH] MTD: make mtd->name const Martin Waitz
@ 2006-04-24  7:24 ` Jörn Engel
  0 siblings, 0 replies; 2+ messages in thread
From: Jörn Engel @ 2006-04-24  7:24 UTC (permalink / raw)
  To: linux-mtd

On Sun, 23 April 2006 21:34:39 +0200, Martin Waitz wrote:
> 
> mtd->name is never used read-write and often holds a pointer to constant data.
> 
> Signed-off-by: Martin Waitz <tali@admingilde.org>

Applied, thanks.

Jörn

-- 
To my face you have the audacity to advise me to become a thief - the worst
kind of thief that is conceivable, a thief of spiritual things, a thief of
ideas! It is insufferable, intolerable!
-- M. Binet in Scarabouche

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-04-24  7:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-23 19:34 [PATCH] MTD: make mtd->name const Martin Waitz
2006-04-24  7:24 ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox