Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the assignment operation is redundant? #33

Closed
liyangorg opened this issue Apr 11, 2019 · 1 comment
Closed

Is the assignment operation is redundant? #33

liyangorg opened this issue Apr 11, 2019 · 1 comment

Comments

@liyangorg
Copy link

liyangorg commented Apr 11, 2019

dev->cdev.ops = &scull_fops;

Hi, martinezjavier.

The assignment operation: "dev->cdev.ops = &scull_fops;", already included in function cdev_init, whether in v2.6.12 or in v5.1-rc4.

so, the assignment is redundant?

The following code is taken from :
https://github.com/torvalds/linux/blob/master/fs/char_dev.c
v5.1-rc4

/**
 * cdev_init() - initialize a cdev structure
 * @cdev: the structure to initialize
 * @fops: the file_operations for this device
 *
 * Initializes @cdev, remembering @fops, making it ready to add to the
 * system with cdev_add().
 */
void cdev_init(struct cdev *cdev, const struct file_operations *fops)
{
	memset(cdev, 0, sizeof *cdev);
	INIT_LIST_HEAD(&cdev->list);
	kobject_init(&cdev->kobj, &ktype_cdev_default);
	cdev->ops = fops;
}
dwalkes pushed a commit to cu-ecen-aeld/ldd3 that referenced this issue Aug 30, 2020
dwalkes pushed a commit that referenced this issue Aug 30, 2020
See #33
Based on https://github.com/torvalds/linux/blame/master/fs/char_dev.c#L656
fops has been set in cdev_init since at least 2.6.12.
@dwalkes
Copy link
Collaborator

dwalkes commented Aug 30, 2020

so, the assignment is redundant?

I believe so! Fixed in #48

@dwalkes dwalkes closed this as completed Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants