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

Commit 2d3da59f authored by Markus Elfring's avatar Markus Elfring Committed by Mauro Carvalho Chehab
Browse files

media: drivers: improve a size determination



Replace the specification of a data structure by a pointer dereference
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.

[mchehab@s-opensoure.com: merge similar patches into one]

Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarHans Verkuil <hansverk@cisco.com>
parent d303b7c5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ int cypress_load_firmware(struct usb_device *udev,
	struct hexline *hx;
	int ret, pos = 0;

	hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
	hx = kmalloc(sizeof(*hx), GFP_KERNEL);
	if (!hx)
		return -ENOMEM;

+6 −8
Original line number Diff line number Diff line
@@ -447,7 +447,7 @@ static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
			return entry;
		}
	}
	entry = kmalloc(sizeof(struct smscore_registry_entry_t), GFP_KERNEL);
	entry = kmalloc(sizeof(*entry), GFP_KERNEL);
	if (entry) {
		entry->mode = default_mode;
		strcpy(entry->devpath, devpath);
@@ -536,9 +536,7 @@ int smscore_register_hotplug(hotplug_t hotplug)
	int rc = 0;

	kmutex_lock(&g_smscore_deviceslock);

	notifyee = kmalloc(sizeof(struct smscore_device_notifyee_t),
			   GFP_KERNEL);
	notifyee = kmalloc(sizeof(*notifyee), GFP_KERNEL);
	if (notifyee) {
		/* now notify callback about existing devices */
		first = &g_smscore_devices;
@@ -627,7 +625,7 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
{
	struct smscore_buffer_t *cb;

	cb = kzalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
	cb = kzalloc(sizeof(*cb), GFP_KERNEL);
	if (!cb)
		return NULL;

@@ -655,7 +653,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
	struct smscore_device_t *dev;
	u8 *buffer;

	dev = kzalloc(sizeof(struct smscore_device_t), GFP_KERNEL);
	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
	if (!dev)
		return -ENOMEM;

@@ -1684,7 +1682,7 @@ static int smscore_validate_client(struct smscore_device_t *coredev,
		pr_err("The msg ID already registered to another client.\n");
		return -EEXIST;
	}
	listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL);
	listentry = kzalloc(sizeof(*listentry), GFP_KERNEL);
	if (!listentry)
		return -ENOMEM;

@@ -1721,7 +1719,7 @@ int smscore_register_client(struct smscore_device_t *coredev,
		return -EEXIST;
	}

	newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL);
	newclient = kzalloc(sizeof(*newclient), GFP_KERNEL);
	if (!newclient)
		return -ENOMEM;

+1 −1
Original line number Diff line number Diff line
@@ -455,7 +455,7 @@ struct dvb_frontend *as102_attach(const char *name,
	struct as102_state *state;
	struct dvb_frontend *fe;

	state = kzalloc(sizeof(struct as102_state), GFP_KERNEL);
	state = kzalloc(sizeof(*state), GFP_KERNEL);
	if (!state)
		return NULL;

+1 −2
Original line number Diff line number Diff line
@@ -552,8 +552,7 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
		const struct cx24113_config *config, struct i2c_adapter *i2c)
{
	/* allocate memory for the internal state */
	struct cx24113_state *state =
		kzalloc(sizeof(struct cx24113_state), GFP_KERNEL);
	struct cx24113_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
	int rc;

	if (!state)
+1 −1
Original line number Diff line number Diff line
@@ -1126,7 +1126,7 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
	dprintk("%s\n", __func__);

	/* allocate memory for the internal state */
	state = kzalloc(sizeof(struct cx24116_state), GFP_KERNEL);
	state = kzalloc(sizeof(*state), GFP_KERNEL);
	if (state == NULL)
		goto error1;

Loading