mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kevin Corry <kevcorry@us.ibm.com>
To: LKML <linux-kernel@vger.kernel.org>, Andrew Morton <akpm@osdl.org>
Subject: [PATCH] Device-Mapper 9/9
Date: Mon, 12 Apr 2004 09:19:22 -0500	[thread overview]
Message-ID: <200404120919.22092.kevcorry@us.ibm.com> (raw)
In-Reply-To: <200404120912.45870.kevcorry@us.ibm.com>

Striped: Use an EMIT macro in the status function.

--- diff/drivers/md/dm-stripe.c	2004-04-03 21:37:06.000000000 -0600
+++ source/drivers/md/dm-stripe.c	2004-04-09 09:42:55.000000000 -0500
@@ -187,24 +187,24 @@
 			 status_type_t type, char *result, unsigned int maxlen)
 {
 	struct stripe_c *sc = (struct stripe_c *) ti->private;
-	int offset;
+	unsigned int sz = 0;
 	unsigned int i;
 	char buffer[32];
 
+#define EMIT(x...) sz += ((sz >= maxlen) ? \
+			  0 : scnprintf(result + sz, maxlen - sz, x))
+
 	switch (type) {
 	case STATUSTYPE_INFO:
 		result[0] = '\0';
 		break;
 
 	case STATUSTYPE_TABLE:
-		offset = scnprintf(result, maxlen, "%d " SECTOR_FORMAT,
-				  sc->stripes, sc->chunk_mask + 1);
+		EMIT("%d " SECTOR_FORMAT, sc->stripes, sc->chunk_mask + 1);
 		for (i = 0; i < sc->stripes; i++) {
 			format_dev_t(buffer, sc->stripe[i].dev->bdev->bd_dev);
-			offset +=
-			    scnprintf(result + offset, maxlen - offset,
-				     " %s " SECTOR_FORMAT, buffer,
-				     sc->stripe[i].physical_start);
+			EMIT(" %s " SECTOR_FORMAT, buffer,
+			     sc->stripe[i].physical_start);
 		}
 		break;
 	}

      parent reply	other threads:[~2004-04-12 14:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-12 14:12 [PATCH] Device-Mapper 0/9 Kevin Corry
2004-04-12 14:18 ` [PATCH] Device-Mapper 1/9 Kevin Corry
2004-04-12 14:18 ` [PATCH] Device-Mapper 2/9 Kevin Corry
2004-04-12 14:18 ` [PATCH] Device-Mapper 3/9 Kevin Corry
2004-04-12 14:18 ` [PATCH] Device-Mapper 4/9 Kevin Corry
2004-04-12 14:18 ` [PATCH] Device-Mapper 5/9 Kevin Corry
2004-04-12 14:18 ` [PATCH] Device-Mapper 6/9 Kevin Corry
2004-04-12 14:19 ` [PATCH] Device-Mapper 7/9 Kevin Corry
2004-04-12 14:19 ` [PATCH] Device-Mapper 8/9 Kevin Corry
2004-04-12 14:19 ` Kevin Corry [this message]

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=200404120919.22092.kevcorry@us.ibm.com \
    --to=kevcorry@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®