From 93b35f7819aa6ae69d9d5aaf359694f384d4a7d1 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Tue, 8 Oct 2024 00:34:36 +0800 Subject: [PATCH] Fix function declaration The function pointer type of myvariable_store was incompatible with the store member of struct kobj_attribute, leading to a compilation error when the type conversion (void *) was omitted. This patch corrects the function declaration and eliminates the need for type conversion. --- examples/hello-sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/hello-sysfs.c b/examples/hello-sysfs.c index 6e4f7cf3..20cdffc6 100644 --- a/examples/hello-sysfs.c +++ b/examples/hello-sysfs.c @@ -20,7 +20,7 @@ static ssize_t myvariable_show(struct kobject *kobj, } static ssize_t myvariable_store(struct kobject *kobj, - struct kobj_attribute *attr, char *buf, + struct kobj_attribute *attr, const char *buf, size_t count) { sscanf(buf, "%du", &myvariable); @@ -28,7 +28,7 @@ static ssize_t myvariable_store(struct kobject *kobj, } static struct kobj_attribute myvariable_attribute = - __ATTR(myvariable, 0660, myvariable_show, (void *)myvariable_store); + __ATTR(myvariable, 0660, myvariable_show, myvariable_store); static int __init mymodule_init(void) {