Commit ee2e992c authored by Li Zefan's avatar Li Zefan Committed by Jens Axboe

block: simplify string handling in elv_iosched_store()

strlcpy() guarantees the dest buffer is NULL teminated.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent e6d63840
...@@ -1166,15 +1166,10 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name, ...@@ -1166,15 +1166,10 @@ ssize_t elv_iosched_store(struct request_queue *q, const char *name,
size_t count) size_t count)
{ {
char elevator_name[ELV_NAME_MAX]; char elevator_name[ELV_NAME_MAX];
size_t len;
struct elevator_type *e; struct elevator_type *e;
elevator_name[sizeof(elevator_name) - 1] = '\0'; strlcpy(elevator_name, name, sizeof(elevator_name));
strncpy(elevator_name, name, sizeof(elevator_name) - 1); strstrip(elevator_name);
len = strlen(elevator_name);
if (len && elevator_name[len - 1] == '\n')
elevator_name[len - 1] = '\0';
e = elevator_get(elevator_name); e = elevator_get(elevator_name);
if (!e) { if (!e) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment