[PATCH] Device-Mapper 9/9

From: Kevin Corry
Date: Mon Apr 12 2004 - 09:26:58 EST


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;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/