diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2008-10-14 02:49:56 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-17 02:46:57 -0400 |
commit | ee2e992cc28553f6c4dd1ab5483c8733c393626b (patch) | |
tree | 1947e8cb26f1018c20f89db93e06698cc17353f5 | |
parent | e6d63840ba55ffd3a79aea6792aac6f29f338083 (diff) |
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>
-rw-r--r-- | block/elevator.c | 9 |
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, | |||
1166 | size_t count) | 1166 | size_t count) |
1167 | { | 1167 | { |
1168 | char elevator_name[ELV_NAME_MAX]; | 1168 | char elevator_name[ELV_NAME_MAX]; |
1169 | size_t len; | ||
1170 | struct elevator_type *e; | 1169 | struct elevator_type *e; |
1171 | 1170 | ||
1172 | elevator_name[sizeof(elevator_name) - 1] = '\0'; | 1171 | strlcpy(elevator_name, name, sizeof(elevator_name)); |
1173 | strncpy(elevator_name, name, sizeof(elevator_name) - 1); | 1172 | strstrip(elevator_name); |
1174 | len = strlen(elevator_name); | ||
1175 | |||
1176 | if (len && elevator_name[len - 1] == '\n') | ||
1177 | elevator_name[len - 1] = '\0'; | ||
1178 | 1173 | ||
1179 | e = elevator_get(elevator_name); | 1174 | e = elevator_get(elevator_name); |
1180 | if (!e) { | 1175 | if (!e) { |