]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Input: switch to using sizeof(*type) when allocating memory
authorMarkus Elfring <elfring@users.sourceforge.net>
Wed, 10 May 2017 00:51:30 +0000 (17:51 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 10 May 2017 21:39:34 +0000 (14:39 -0700)
Instead of specifying type explicitly, derive it from the type of pointer
when allocating memory, which is considered safer practice.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/input.c

index 067a6edd643cf33005b98a357a471959d6f1842e..7e6842bd525c679a808c0e39bab7c5c4711f72ba 100644 (file)
@@ -481,7 +481,7 @@ EXPORT_SYMBOL(input_inject_event);
 void input_alloc_absinfo(struct input_dev *dev)
 {
        if (!dev->absinfo)
-               dev->absinfo = kcalloc(ABS_CNT, sizeof(struct input_absinfo),
+               dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo),
                                        GFP_KERNEL);
 
        WARN(!dev->absinfo, "%s(): kcalloc() failed?\n", __func__);
@@ -1783,7 +1783,7 @@ struct input_dev *input_allocate_device(void)
        static atomic_t input_no = ATOMIC_INIT(-1);
        struct input_dev *dev;
 
-       dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (dev) {
                dev->dev.type = &input_dev_type;
                dev->dev.class = &input_class;
@@ -1849,7 +1849,7 @@ struct input_dev *devm_input_allocate_device(struct device *dev)
        struct input_devres *devres;
 
        devres = devres_alloc(devm_input_device_release,
-                             sizeof(struct input_devres), GFP_KERNEL);
+                             sizeof(*devres), GFP_KERNEL);
        if (!devres)
                return NULL;
 
@@ -2099,7 +2099,7 @@ int input_register_device(struct input_dev *dev)
 
        if (dev->devres_managed) {
                devres = devres_alloc(devm_input_device_unregister,
-                                     sizeof(struct input_devres), GFP_KERNEL);
+                                     sizeof(*devres), GFP_KERNEL);
                if (!devres)
                        return -ENOMEM;