Get rid of magic numbers in drivers/block/genhd.c
PATCH 1/1 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é
drivers/block/genhd.c +2 -2
@@ -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 ;/*
fs/partitions/check.c +1 -1
@@ -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).
Quoted 6 lines · René Scharfe
Hi Christoph,
a few days ago you cleaned up
disk_name()infs/partitions/check.c. It is now guaranteed to write no more thanBDEVNAME_SIZEinto the provided buffer.
Quoted 6 lines
There are two buffers in
drivers/block/genhd.c, that are used solely for callingdisk_name(), and have a size of 64. The patch below replaces these magic numbers withBDEVNAME_SIZE.Additionally it corrects the comment at the top of
disk_name(): The md driver does not call that function, the genhd driver does.
Looks fine to me.
Rusty, is the trivial patch bot still active? I haven't seen Marcelo or Linus merging trivial patches for ages (or maybe I've missed something?)
In message <[email protected]> you write:
Quoted 3 lines
Rusty, is the trivial patch bot still active? I haven't seen Marcelo or Linus merging trivial patches for ages (or maybe I've missed something?)
Yes, still active. Their scripts used to take the last From:, so I put the original author in a fake From line in the body. Someone "fixed" the scripts, so now they seem to come from me.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.