Messages in this thread Patch in this message | | | Date | Sun, 4 May 2003 00:04:25 +0200 | From | René Scharfe <> | Subject | [PATCH 2.5] [TRIVIAL] Get rid of magic numbers in drivers/block/genhd.c |
| |
Hi Christoph,
a few days ago you cleaned up disk_name() in fs/partitions/check.c. It is now guaranteed to write no more than BDEVNAME_SIZE into the provided buffer.
There are two buffers in drivers/block/genhd.c, that are used solely for calling disk_name(), and have a size of 64. The patch below replaces these magic numbers with BDEVNAME_SIZE.
Additionally it corrects the comment at the top of disk_name(): The md driver does not call that function, the genhd driver does.
René
diff -ur l-x/drivers/block/genhd.c l-y/drivers/block/genhd.c --- l-x/drivers/block/genhd.c 2003-05-03 21:37:47.000000000 +0200 +++ l-y/drivers/block/genhd.c 2003-05-03 23:58:35.000000000 +0200 @@ -350,7 +350,7 @@ { struct gendisk *sgp = v; int n; - char buf[64]; + char buf[BDEVNAME_SIZE]; if (&sgp->kobj.entry == block_subsys.kset.list.next) seq_puts(part, "major minor #blocks name\n\n"); @@ -583,7 +583,7 @@ static int diskstats_show(struct seq_file *s, void *v) { struct gendisk *gp = v; - char buf[64]; + char buf[BDEVNAME_SIZE]; int n = 0; /* diff -ur l-x/fs/partitions/check.c l-y/fs/partitions/check.c --- l-x/fs/partitions/check.c 2003-05-03 21:37:59.000000000 +0200 +++ l-y/fs/partitions/check.c 2003-05-03 23:58:58.000000000 +0200 @@ -88,7 +88,7 @@ }; /* - * disk_name() is used by partition check code and the md driver. + * disk_name() is used by partition check code and the genhd driver. * It formats the devicename of the indicated disk into * the supplied buffer (of size at least 32), and returns * a pointer to that same buffer (for convenience). - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |