From 1a1e01f5696e5ea2e1d0a5a7e6fa9c3bf7a8778b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Tue, 26 Aug 2014 01:31:49 +0200 Subject: [PATCH] Use the KLGD command struct as intended. --- klgdff.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/klgdff.c b/klgdff.c index c0fae08..763355f 100644 --- a/klgdff.c +++ b/klgdff.c @@ -16,32 +16,36 @@ static struct klgd_plugin *ff_plugin; static struct klgd_command * klgdff_erase(struct input_dev *dev, const struct ff_effect *effect, const int id) { char *text = kasprintf(GFP_KERNEL, "Erasing effect, type %d, id %d", effect->type, id); - struct klgd_command *c = klgd_alloc_cmd(strlen(text) + 1); - c->bytes = text; + size_t len = strlen(text); + struct klgd_command *c = klgd_alloc_cmd(len + 1); + memcpy(c->bytes, text, len); return c; } static struct klgd_command * klgdff_start(struct input_dev *de, const struct ff_effect *effect, const int id) { char *text = kasprintf(GFP_KERNEL, "Playing effect, type %d, id %d", effect->type, id); - struct klgd_command *c = klgd_alloc_cmd(strlen(text) + 1); - c->bytes = text; + size_t len = strlen(text); + struct klgd_command *c = klgd_alloc_cmd(len + 1); + memcpy(c->bytes, text, len); return c; } static struct klgd_command * klgdff_stop(struct input_dev *dev, const struct ff_effect *effect, const int id) { char *text = kasprintf(GFP_KERNEL, "Stopping effect, type %d, id %d", effect->type, id); - struct klgd_command *c = klgd_alloc_cmd(strlen(text) + 1); - c->bytes = text; + size_t len = strlen(text); + struct klgd_command *c = klgd_alloc_cmd(len + 1); + memcpy(c->bytes, text, len); return c; } static struct klgd_command * klgdff_upload(struct input_dev *dev, const struct ff_effect *effect, const int id) { char *text = kasprintf(GFP_KERNEL, "Uploading effect, type %d, id %d", effect->type, id); - struct klgd_command *c = klgd_alloc_cmd(strlen(text) + 1); - c->bytes = text; + size_t len = strlen(text); + struct klgd_command *c = klgd_alloc_cmd(len + 1); + memcpy(c->bytes, text, len); return c; } -- 2.43.5