public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-kernel@vger.kernel.org, trivial@rustcorp.com.au
Subject: [PATCH 2.5] [TRIVIAL] Get rid of magic numbers in drivers/block/genhd.c
Date: Sun, 4 May 2003 00:04:25 +0200	[thread overview]
Message-ID: <20030504000425.726daf8b.l.s.r@web.de> (raw)

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

             reply	other threads:[~2003-05-03 21:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-03 22:04 René Scharfe [this message]
2003-05-04  5:55 ` [PATCH 2.5] [TRIVIAL] Get rid of magic numbers in drivers/block/genhd.c Christoph Hellwig
2003-05-05  4:42   ` Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030504000425.726daf8b.l.s.r@web.de \
    --to=l.s.r@web.de \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@rustcorp.com.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox