Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24674065 authored by Markus Elfring's avatar Markus Elfring Committed by Martyn Welch
Browse files

vme: fake: Improve five size determinations in fake_init()



Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarMartyn Welch <martyn@welchs.me.uk>
parent ef544fbc
Loading
Loading
Loading
Loading
+5 −7
Original line number Original line Diff line number Diff line
@@ -1075,13 +1075,13 @@ static int __init fake_init(void)
	/* If we want to support more than one bridge at some point, we need to
	/* If we want to support more than one bridge at some point, we need to
	 * dynamically allocate this so we get one per device.
	 * dynamically allocate this so we get one per device.
	 */
	 */
	fake_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL);
	fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL);
	if (fake_bridge == NULL) {
	if (fake_bridge == NULL) {
		retval = -ENOMEM;
		retval = -ENOMEM;
		goto err_struct;
		goto err_struct;
	}
	}


	fake_device = kzalloc(sizeof(struct fake_driver), GFP_KERNEL);
	fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL);
	if (fake_device == NULL) {
	if (fake_device == NULL) {
		retval = -ENOMEM;
		retval = -ENOMEM;
		goto err_driver;
		goto err_driver;
@@ -1104,8 +1104,7 @@ static int __init fake_init(void)
	/* Add master windows to list */
	/* Add master windows to list */
	INIT_LIST_HEAD(&fake_bridge->master_resources);
	INIT_LIST_HEAD(&fake_bridge->master_resources);
	for (i = 0; i < FAKE_MAX_MASTER; i++) {
	for (i = 0; i < FAKE_MAX_MASTER; i++) {
		master_image = kmalloc(sizeof(struct vme_master_resource),
		master_image = kmalloc(sizeof(*master_image), GFP_KERNEL);
				GFP_KERNEL);
		if (master_image == NULL) {
		if (master_image == NULL) {
			retval = -ENOMEM;
			retval = -ENOMEM;
			goto err_master;
			goto err_master;
@@ -1131,8 +1130,7 @@ static int __init fake_init(void)
	/* Add slave windows to list */
	/* Add slave windows to list */
	INIT_LIST_HEAD(&fake_bridge->slave_resources);
	INIT_LIST_HEAD(&fake_bridge->slave_resources);
	for (i = 0; i < FAKE_MAX_SLAVE; i++) {
	for (i = 0; i < FAKE_MAX_SLAVE; i++) {
		slave_image = kmalloc(sizeof(struct vme_slave_resource),
		slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL);
				GFP_KERNEL);
		if (slave_image == NULL) {
		if (slave_image == NULL) {
			retval = -ENOMEM;
			retval = -ENOMEM;
			goto err_slave;
			goto err_slave;
@@ -1154,7 +1152,7 @@ static int __init fake_init(void)


	/* Add location monitor to list */
	/* Add location monitor to list */
	INIT_LIST_HEAD(&fake_bridge->lm_resources);
	INIT_LIST_HEAD(&fake_bridge->lm_resources);
	lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
	lm = kmalloc(sizeof(*lm), GFP_KERNEL);
	if (lm == NULL) {
	if (lm == NULL) {
		retval = -ENOMEM;
		retval = -ENOMEM;
		goto err_lm;
		goto err_lm;