Skip to content

Commit

Permalink
Correct the function type
Browse files Browse the repository at this point in the history
The function type of myvariable_store is different from the member
.store in struct kobj_attribute. So, we will meet a compilation
error with incompatable-pointer-types if we omit the type
conversion (void *). This patch corrects the function type and discard
the type conversion.
  • Loading branch information
NOVBobLee committed Oct 7, 2024
1 parent 2eadbb1 commit 5605348
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/hello-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ 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);
return count;
}

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)
{
Expand Down

0 comments on commit 5605348

Please sign in to comment.