2003-05-03 21:38:06

by Ren

[permalink] [raw]
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).


2003-05-04 05:42:39

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 2.5] [TRIVIAL] Get rid of magic numbers in drivers/block/genhd.c

On Sun, May 04, 2003 at 12:04:25AM +0200, Ren? Scharfe wrote:
> 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.

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?)

2003-05-05 04:34:24

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH 2.5] [TRIVIAL] Get rid of magic numbers in drivers/block/genhd.c

In message <[email protected]> you write:
> 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.