dm-buffered: clean up handling of bc->start Don't cast arguments to kstrtoull. The test "bc->start >= (ti->len >> 1)" is not needed. Signed-off-by: Mikulas Patocka --- drivers/md/dm-buffered-target.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) Index: linux-2.6/drivers/md/dm-buffered-target.c =================================================================== --- linux-2.6.orig/drivers/md/dm-buffered-target.c +++ linux-2.6/drivers/md/dm-buffered-target.c @@ -372,6 +372,7 @@ static int buffered_ctr(struct dm_target { struct buffered_c *bc; int i, r; + unsigned long long start; if (argc < 2) { ti->error = "Requires at least 2 arguments"; @@ -386,12 +387,12 @@ static int buffered_ctr(struct dm_target ti->private = bc; - r = (kstrtoull(argv[1], 10, (u64 *)&bc->start) || - bc->start >= (ti->len >> 1)) ? -EINVAL : 0; + r = kstrtoull(argv[1], 10, &start); if (r) { ti->error = "Invalid sector offset"; goto bad; } + bc->start = start; for (i = 2; i < argc; i++) { const char *arg = argv[i]; @@ -550,7 +551,7 @@ static void buffered_status(struct dm_ta switch (type) { case STATUSTYPE_TABLE: - DMEMIT("%s %llu", bc->dev->name, (u64)bc->start); + DMEMIT("%s %llu", bc->dev->name, (unsigned long long)bc->start); if (bc->buffer_size_set) DMEMIT(" block_size:%u", bc->buffer_size); if (bc->discard_set) @@ -599,7 +600,7 @@ static int buffered_message(struct dm_ta char *result, unsigned int maxlen) { struct buffered_c *bc = ti->private; - sector_t n; + unsigned long long n; if (!strcasecmp(argv[0], "async_flush")) { if (argc != 1) @@ -611,7 +612,7 @@ static int buffered_message(struct dm_ta if (!strcasecmp(argv[0], "buffers")) { if (argc != 2) return -EINVAL; - if (kstrtoull(argv[1], 10, (u64 *)&n) || !n || + if (kstrtoull(argv[1], 10, &n) || !n || n >= _buffered_size(ti) || n > UINT_MAX) return -EINVAL; dm_bufio_set_minimum_buffers(bc->bufio, (unsigned int)n);