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

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
...@@ -74,7 +74,7 @@ int cypress_load_firmware(struct usb_device *udev, ...@@ -74,7 +74,7 @@ int cypress_load_firmware(struct usb_device *udev,
struct hexline *hx; struct hexline *hx;
int ret, pos = 0; int ret, pos = 0;
hx = kmalloc(sizeof(struct hexline), GFP_KERNEL); hx = kmalloc(sizeof(*hx), GFP_KERNEL);
if (!hx) if (!hx)
return -ENOMEM; return -ENOMEM;
......
...@@ -447,7 +447,7 @@ static struct smscore_registry_entry_t *smscore_find_registry(char *devpath) ...@@ -447,7 +447,7 @@ static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
return entry; return entry;
} }
} }
entry = kmalloc(sizeof(struct smscore_registry_entry_t), GFP_KERNEL); entry = kmalloc(sizeof(*entry), GFP_KERNEL);
if (entry) { if (entry) {
entry->mode = default_mode; entry->mode = default_mode;
strcpy(entry->devpath, devpath); strcpy(entry->devpath, devpath);
...@@ -536,9 +536,7 @@ int smscore_register_hotplug(hotplug_t hotplug) ...@@ -536,9 +536,7 @@ int smscore_register_hotplug(hotplug_t hotplug)
int rc = 0; int rc = 0;
kmutex_lock(&g_smscore_deviceslock); kmutex_lock(&g_smscore_deviceslock);
notifyee = kmalloc(sizeof(*notifyee), GFP_KERNEL);
notifyee = kmalloc(sizeof(struct smscore_device_notifyee_t),
GFP_KERNEL);
if (notifyee) { if (notifyee) {
/* now notify callback about existing devices */ /* now notify callback about existing devices */
first = &g_smscore_devices; first = &g_smscore_devices;
...@@ -627,7 +625,7 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer, ...@@ -627,7 +625,7 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
{ {
struct smscore_buffer_t *cb; struct smscore_buffer_t *cb;
cb = kzalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL); cb = kzalloc(sizeof(*cb), GFP_KERNEL);
if (!cb) if (!cb)
return NULL; return NULL;
...@@ -655,7 +653,7 @@ int smscore_register_device(struct smsdevice_params_t *params, ...@@ -655,7 +653,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
struct smscore_device_t *dev; struct smscore_device_t *dev;
u8 *buffer; u8 *buffer;
dev = kzalloc(sizeof(struct smscore_device_t), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
...@@ -1684,7 +1682,7 @@ static int smscore_validate_client(struct smscore_device_t *coredev, ...@@ -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"); pr_err("The msg ID already registered to another client.\n");
return -EEXIST; return -EEXIST;
} }
listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL); listentry = kzalloc(sizeof(*listentry), GFP_KERNEL);
if (!listentry) if (!listentry)
return -ENOMEM; return -ENOMEM;
...@@ -1721,7 +1719,7 @@ int smscore_register_client(struct smscore_device_t *coredev, ...@@ -1721,7 +1719,7 @@ int smscore_register_client(struct smscore_device_t *coredev,
return -EEXIST; return -EEXIST;
} }
newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL); newclient = kzalloc(sizeof(*newclient), GFP_KERNEL);
if (!newclient) if (!newclient)
return -ENOMEM; return -ENOMEM;
......
...@@ -455,7 +455,7 @@ struct dvb_frontend *as102_attach(const char *name, ...@@ -455,7 +455,7 @@ struct dvb_frontend *as102_attach(const char *name,
struct as102_state *state; struct as102_state *state;
struct dvb_frontend *fe; struct dvb_frontend *fe;
state = kzalloc(sizeof(struct as102_state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
return NULL; return NULL;
......
...@@ -552,8 +552,7 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe, ...@@ -552,8 +552,7 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
const struct cx24113_config *config, struct i2c_adapter *i2c) const struct cx24113_config *config, struct i2c_adapter *i2c)
{ {
/* allocate memory for the internal state */ /* allocate memory for the internal state */
struct cx24113_state *state = struct cx24113_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
kzalloc(sizeof(struct cx24113_state), GFP_KERNEL);
int rc; int rc;
if (!state) if (!state)
......
...@@ -1126,7 +1126,7 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config, ...@@ -1126,7 +1126,7 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
dprintk("%s\n", __func__); dprintk("%s\n", __func__);
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(struct cx24116_state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (state == NULL) if (state == NULL)
goto error1; goto error1;
......
...@@ -839,7 +839,7 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config, ...@@ -839,7 +839,7 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
dprintk("%s\n", __func__); dprintk("%s\n", __func__);
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(struct ds3000_state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
goto error2; goto error2;
......
...@@ -2071,7 +2071,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, ...@@ -2071,7 +2071,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
dev_dbg(&i2c->dev, "%s called.\n", __func__); dev_dbg(&i2c->dev, "%s called.\n", __func__);
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
goto error; goto error;
......
...@@ -381,7 +381,7 @@ static int sp2_probe(struct i2c_client *client, ...@@ -381,7 +381,7 @@ static int sp2_probe(struct i2c_client *client,
dev_dbg(&client->dev, "\n"); dev_dbg(&client->dev, "\n");
s = kzalloc(sizeof(struct sp2), GFP_KERNEL); s = kzalloc(sizeof(*s), GFP_KERNEL);
if (!s) { if (!s) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
......
...@@ -3467,7 +3467,7 @@ static int adv7842_probe(struct i2c_client *client, ...@@ -3467,7 +3467,7 @@ static int adv7842_probe(struct i2c_client *client,
return -ENODEV; return -ENODEV;
} }
state = devm_kzalloc(&client->dev, sizeof(struct adv7842_state), GFP_KERNEL); state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
if (!state) if (!state)
return -ENOMEM; return -ENOMEM;
......
...@@ -909,7 +909,7 @@ static int cx18_probe(struct pci_dev *pci_dev, ...@@ -909,7 +909,7 @@ static int cx18_probe(struct pci_dev *pci_dev,
return -ENOMEM; return -ENOMEM;
} }
cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC); cx = kzalloc(sizeof(*cx), GFP_ATOMIC);
if (!cx) if (!cx)
return -ENOMEM; return -ENOMEM;
......
...@@ -163,7 +163,7 @@ static int hopper_pci_probe(struct pci_dev *pdev, ...@@ -163,7 +163,7 @@ static int hopper_pci_probe(struct pci_dev *pdev,
struct mantis_hwconfig *config; struct mantis_hwconfig *config;
int err; int err;
mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
if (mantis == NULL) { if (mantis == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto fail0; goto fail0;
......
...@@ -173,7 +173,7 @@ static int mantis_pci_probe(struct pci_dev *pdev, ...@@ -173,7 +173,7 @@ static int mantis_pci_probe(struct pci_dev *pdev,
struct mantis_hwconfig *config; struct mantis_hwconfig *config;
int err; int err;
mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); mantis = kzalloc(sizeof(*mantis), GFP_KERNEL);
if (!mantis) if (!mantis)
return -ENOMEM; return -ENOMEM;
......
...@@ -260,7 +260,7 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d ...@@ -260,7 +260,7 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
DEB_EE("\n"); DEB_EE("\n");
hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); hexium = kzalloc(sizeof(*hexium), GFP_KERNEL);
if (!hexium) if (!hexium)
return -ENOMEM; return -ENOMEM;
......
...@@ -219,7 +219,7 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -219,7 +219,7 @@ static int hexium_probe(struct saa7146_dev *dev)
return -EFAULT; return -EFAULT;
} }
hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); hexium = kzalloc(sizeof(*hexium), GFP_KERNEL);
if (!hexium) if (!hexium)
return -ENOMEM; return -ENOMEM;
......
...@@ -98,7 +98,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port, ...@@ -98,7 +98,7 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
goto ret; goto ret;
} }
buf = kzalloc(sizeof(struct saa7164_buffer), GFP_KERNEL); buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf) if (!buf)
goto ret; goto ret;
...@@ -281,7 +281,7 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev, ...@@ -281,7 +281,7 @@ struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
{ {
struct saa7164_user_buffer *buf; struct saa7164_user_buffer *buf;
buf = kzalloc(sizeof(struct saa7164_user_buffer), GFP_KERNEL); buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf) if (!buf)
return NULL; return NULL;
......
...@@ -1505,7 +1505,7 @@ static int isc_formats_init(struct isc_device *isc) ...@@ -1505,7 +1505,7 @@ static int isc_formats_init(struct isc_device *isc)
isc->num_user_formats = num_fmts; isc->num_user_formats = num_fmts;
isc->user_formats = devm_kcalloc(isc->dev, isc->user_formats = devm_kcalloc(isc->dev,
num_fmts, sizeof(struct isc_format *), num_fmts, sizeof(*isc->user_formats),
GFP_KERNEL); GFP_KERNEL);
if (!isc->user_formats) if (!isc->user_formats)
return -ENOMEM; return -ENOMEM;
......
...@@ -1421,7 +1421,7 @@ static int zr364xx_probe(struct usb_interface *intf, ...@@ -1421,7 +1421,7 @@ static int zr364xx_probe(struct usb_interface *intf,
le16_to_cpu(udev->descriptor.idVendor), le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct)); le16_to_cpu(udev->descriptor.idProduct));
cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL); cam = kzalloc(sizeof(*cam), GFP_KERNEL);
if (!cam) if (!cam)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment