OSDN Git Service

[media] i2c: Improve a size determination
authorMarkus Elfring <elfring@users.sourceforge.net>
Sat, 2 Sep 2017 14:09:35 +0000 (11:09 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 4 Oct 2017 20:15:39 +0000 (17:15 -0300)
Replace the specification of a data structure by pointer dereferences
as the parameter for the operator "sizeof" to make size
determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

[mchehab@s-opensource.com: merged similar patches]
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/i2c/ov2640.c
drivers/media/i2c/soc_camera/ov9640.c
drivers/media/i2c/soc_camera/ov9740.c

index c0d0c50..cc3882c 100644 (file)
@@ -1097,7 +1097,7 @@ static int ov2640_probe(struct i2c_client *client,
                return -EIO;
        }
 
-       priv = devm_kzalloc(&client->dev, sizeof(struct ov2640_priv), GFP_KERNEL);
+       priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
 
index 8835008..c639489 100644 (file)
@@ -675,7 +675,7 @@ static int ov9640_probe(struct i2c_client *client,
                return -EINVAL;
        }
 
-       priv = devm_kzalloc(&client->dev, sizeof(struct ov9640_priv), GFP_KERNEL);
+       priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
 
index f44f5da..755de22 100644 (file)
@@ -935,7 +935,7 @@ static int ov9740_probe(struct i2c_client *client,
                return -EINVAL;
        }
 
-       priv = devm_kzalloc(&client->dev, sizeof(struct ov9740_priv), GFP_KERNEL);
+       priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;