From: Michal MalĂ˝ Date: Mon, 25 Aug 2014 23:31:49 +0000 (+0200) Subject: Use the KLGD command struct as intended. X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=1a1e01f5696e5ea2e1d0a5a7e6fa9c3bf7a8778b;p=KLGD_FF_plugin.git Use the KLGD command struct as intended. --- 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; }