Skip to contentSkip to conversation

mtd_info: name is const most of the time

PATCH New Anton Vorontsov 1 participant 1 message May 26, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd_info: name is const most of the time

There is only one special case - block2mtd, which fills name via sprintf. So use casting there, we know it's safe.

---
 drivers/mtd/cmdlinepart.c       |    2 +-
 drivers/mtd/devices/block2mtd.c |    2 +-
 drivers/mtd/mtdconcat.c         |    2 +-
 include/linux/mtd/concat.h      |    2 +-
 include/linux/mtd/mtd.h         |    2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/cmdlinepart.c +1 -1
index 23fab14..cbb324b 100644
@@ -299,7 +299,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
 	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;
drivers/mtd/devices/block2mtd.c +1 -1
index be4b994..2e7e754 100644
@@ -284,7 +284,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
 	if (!dev->mtd.name)
 		goto devinit_err;
 
-	sprintf(dev->mtd.name, "block2mtd: %s", devname);
+	sprintf((char *)dev->mtd.name, "block2mtd: %s", devname);
 
 	dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
 	dev->mtd.erasesize = erase_size;
drivers/mtd/mtdconcat.c +1 -1
index 41844ea..360a974 100644
@@ -693,7 +693,7 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)
  */
 struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],	/* subdevices to concatenate */
 				   int num_devs,	/* number of subdevices      */
-				   char *name)
+				   const char *name)
 {				/* name for the new device   */
 	int i;
 	size_t size;
include/linux/mtd/concat.h +1 -1
index ed8dc67..0273cb1 100644
@@ -15,7 +15,7 @@
 struct mtd_info *mtd_concat_create(
     struct mtd_info *subdev[],  /* subdevices to concatenate */
     int num_devs,               /* number of subdevices      */
-    char *name);                /* name for the new device   */
+    const char *name);          /* name for the new device   */
 
 void mtd_concat_destroy(struct mtd_info *mtd);
 
include/linux/mtd/mtd.h +1 -1
index fd64ccf..513020a 100644
@@ -121,7 +121,7 @@ struct mtd_info {
 	u_int32_t oobavail;  // Available OOB bytes per block
 
 	// Kernel-only stuff starts here.
-	char *name;
+	const char *name;
 	int index;
 
 	/* ecc layout structure pointer - read only ! */
Signature · 1 line
1.5.1.1-dirty