summaryrefslogtreecommitdiffstats
path: root/block/elevator.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2008-10-14 08:49:56 +0200
committerJens Axboe <jens.axboe@oracle.com>2008-10-17 08:46:57 +0200
commitee2e992cc28553f6c4dd1ab5483c8733c393626b (patch)
tree1947e8cb26f1018c20f89db93e06698cc17353f5 /block/elevator.c
parentblock: fix kernel-doc for blk_alloc_devt() (diff)
downloadlinux-ee2e992cc28553f6c4dd1ab5483c8733c393626b.tar.xz
linux-ee2e992cc28553f6c4dd1ab5483c8733c393626b.zip
block: simplify string handling in elv_iosched_store()
strlcpy() guarantees the dest buffer is NULL teminated. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/block/elevator.c b/block/elevator.c
index 04518921db31..9482ffa1aae6 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -1166,15 +1166,10 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
size_t count)
{
char elevator_name[ELV_NAME_MAX];
- size_t len;
struct elevator_type *e;
- elevator_name[sizeof(elevator_name) - 1] = '\0';
- strncpy(elevator_name, name, sizeof(elevator_name) - 1);
- len = strlen(elevator_name);
-
- if (len && elevator_name[len - 1] == '\n')
- elevator_name[len - 1] = '\0';
+ strlcpy(elevator_name, name, sizeof(elevator_name));
+ strstrip(elevator_name);
e = elevator_get(elevator_name);
if (!e) {