Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: joystick - use sizeof(*pointer) instead of sizeof(type)

It is preferred to use sizeof(*pointer) instead of sizeof(type)
due to the type of the variable can change and one needs not
change the former (unlike the latter).

At the same time refactor the code to not use assignment in "if"
conditions.

This patch has no effect on runtime behavior.

Signed-off-by: Erick Archer <erick.archer@outlook.com>
Link: https://lore.kernel.org/r/AS8PR02MB7237FEA55FAC8A9453F2DA6F8BC42@AS8PR02MB7237.eurprd02.prod.outlook.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Erick Archer and committed by
Dmitry Torokhov
4654c4cc f81d03d4

+30 -26
+1 -1
drivers/input/joystick/a3d.c
··· 249 249 int i; 250 250 int err; 251 251 252 - a3d = kzalloc(sizeof(struct a3d), GFP_KERNEL); 252 + a3d = kzalloc(sizeof(*a3d), GFP_KERNEL); 253 253 input_dev = input_allocate_device(); 254 254 if (!a3d || !input_dev) { 255 255 err = -ENOMEM;
+1 -1
drivers/input/joystick/adi.c
··· 456 456 int i; 457 457 int err; 458 458 459 - port = kzalloc(sizeof(struct adi_port), GFP_KERNEL); 459 + port = kzalloc(sizeof(*port), GFP_KERNEL); 460 460 if (!port) 461 461 return -ENOMEM; 462 462
+2 -1
drivers/input/joystick/analog.c
··· 582 582 int i; 583 583 int err; 584 584 585 - if (!(port = kzalloc(sizeof(struct analog_port), GFP_KERNEL))) 585 + port = kzalloc(sizeof(*port), GFP_KERNEL); 586 + if (!port) 586 587 return -ENOMEM; 587 588 588 589 err = analog_init_port(gameport, drv, port);
+1 -1
drivers/input/joystick/as5011.c
··· 237 237 return -ENODEV; 238 238 } 239 239 240 - as5011 = kmalloc(sizeof(struct as5011_device), GFP_KERNEL); 240 + as5011 = kmalloc(sizeof(*as5011), GFP_KERNEL); 241 241 input_dev = input_allocate_device(); 242 242 if (!as5011 || !input_dev) { 243 243 dev_err(&client->dev,
+1 -1
drivers/input/joystick/cobra.c
··· 141 141 int i, j; 142 142 int err; 143 143 144 - cobra = kzalloc(sizeof(struct cobra), GFP_KERNEL); 144 + cobra = kzalloc(sizeof(*cobra), GFP_KERNEL); 145 145 if (!cobra) 146 146 return -ENOMEM; 147 147
+1 -1
drivers/input/joystick/db9.c
··· 587 587 return; 588 588 } 589 589 590 - db9 = kzalloc(sizeof(struct db9), GFP_KERNEL); 590 + db9 = kzalloc(sizeof(*db9), GFP_KERNEL); 591 591 if (!db9) 592 592 goto err_unreg_pardev; 593 593
+1 -1
drivers/input/joystick/gamecon.c
··· 950 950 return; 951 951 } 952 952 953 - gc = kzalloc(sizeof(struct gc), GFP_KERNEL); 953 + gc = kzalloc(sizeof(*gc), GFP_KERNEL); 954 954 if (!gc) { 955 955 pr_err("Not enough memory\n"); 956 956 goto err_unreg_pardev;
+1 -1
drivers/input/joystick/gf2k.c
··· 222 222 unsigned char data[GF2K_LENGTH]; 223 223 int i, err; 224 224 225 - gf2k = kzalloc(sizeof(struct gf2k), GFP_KERNEL); 225 + gf2k = kzalloc(sizeof(*gf2k), GFP_KERNEL); 226 226 input_dev = input_allocate_device(); 227 227 if (!gf2k || !input_dev) { 228 228 err = -ENOMEM;
+2 -1
drivers/input/joystick/grip.c
··· 284 284 int i, j, t; 285 285 int err; 286 286 287 - if (!(grip = kzalloc(sizeof(struct grip), GFP_KERNEL))) 287 + grip = kzalloc(sizeof(*grip), GFP_KERNEL); 288 + if (!grip) 288 289 return -ENOMEM; 289 290 290 291 grip->gameport = gameport;
+2 -1
drivers/input/joystick/grip_mp.c
··· 632 632 struct grip_mp *grip; 633 633 int err; 634 634 635 - if (!(grip = kzalloc(sizeof(struct grip_mp), GFP_KERNEL))) 635 + grip = kzalloc(sizeof(*grip), GFP_KERNEL); 636 + if (!grip) 636 637 return -ENOMEM; 637 638 638 639 grip->gameport = gameport;
+1 -1
drivers/input/joystick/guillemot.c
··· 163 163 int i, t; 164 164 int err; 165 165 166 - guillemot = kzalloc(sizeof(struct guillemot), GFP_KERNEL); 166 + guillemot = kzalloc(sizeof(*guillemot), GFP_KERNEL); 167 167 input_dev = input_allocate_device(); 168 168 if (!guillemot || !input_dev) { 169 169 err = -ENOMEM;
+1 -1
drivers/input/joystick/interact.c
··· 192 192 int i, t; 193 193 int err; 194 194 195 - interact = kzalloc(sizeof(struct interact), GFP_KERNEL); 195 + interact = kzalloc(sizeof(*interact), GFP_KERNEL); 196 196 input_dev = input_allocate_device(); 197 197 if (!interact || !input_dev) { 198 198 err = -ENOMEM;
+1 -1
drivers/input/joystick/magellan.c
··· 132 132 int err = -ENOMEM; 133 133 int i; 134 134 135 - magellan = kzalloc(sizeof(struct magellan), GFP_KERNEL); 135 + magellan = kzalloc(sizeof(*magellan), GFP_KERNEL); 136 136 input_dev = input_allocate_device(); 137 137 if (!magellan || !input_dev) 138 138 goto fail1;
+1 -1
drivers/input/joystick/maplecontrol.c
··· 102 102 struct input_dev *idev; 103 103 unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]); 104 104 105 - pad = kzalloc(sizeof(struct dc_pad), GFP_KERNEL); 105 + pad = kzalloc(sizeof(*pad), GFP_KERNEL); 106 106 idev = input_allocate_device(); 107 107 if (!pad || !idev) { 108 108 error = -ENOMEM;
+1 -1
drivers/input/joystick/n64joy.c
··· 246 246 int err = 0; 247 247 u32 i, j, found = 0; 248 248 249 - priv = kzalloc(sizeof(struct n64joy_priv), GFP_KERNEL); 249 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 250 250 if (!priv) 251 251 return -ENOMEM; 252 252 mutex_init(&priv->n64joy_mutex);
+1 -1
drivers/input/joystick/sidewinder.c
··· 577 577 578 578 comment[0] = 0; 579 579 580 - sw = kzalloc(sizeof(struct sw), GFP_KERNEL); 580 + sw = kzalloc(sizeof(*sw), GFP_KERNEL); 581 581 buf = kmalloc(SW_LENGTH, GFP_KERNEL); 582 582 idbuf = kmalloc(SW_LENGTH, GFP_KERNEL); 583 583 if (!sw || !buf || !idbuf) {
+1 -1
drivers/input/joystick/spaceball.c
··· 199 199 if ((id = serio->id.id) > SPACEBALL_MAX_ID) 200 200 return -ENODEV; 201 201 202 - spaceball = kmalloc(sizeof(struct spaceball), GFP_KERNEL); 202 + spaceball = kmalloc(sizeof(*spaceball), GFP_KERNEL); 203 203 input_dev = input_allocate_device(); 204 204 if (!spaceball || !input_dev) 205 205 goto fail1;
+1 -1
drivers/input/joystick/spaceorb.c
··· 147 147 int err = -ENOMEM; 148 148 int i; 149 149 150 - spaceorb = kzalloc(sizeof(struct spaceorb), GFP_KERNEL); 150 + spaceorb = kzalloc(sizeof(*spaceorb), GFP_KERNEL); 151 151 input_dev = input_allocate_device(); 152 152 if (!spaceorb || !input_dev) 153 153 goto fail1;
+1 -1
drivers/input/joystick/stinger.c
··· 118 118 struct input_dev *input_dev; 119 119 int err = -ENOMEM; 120 120 121 - stinger = kmalloc(sizeof(struct stinger), GFP_KERNEL); 121 + stinger = kmalloc(sizeof(*stinger), GFP_KERNEL); 122 122 input_dev = input_allocate_device(); 123 123 if (!stinger || !input_dev) 124 124 goto fail1;
+2 -1
drivers/input/joystick/tmdc.c
··· 348 348 int i; 349 349 int err; 350 350 351 - if (!(tmdc = kzalloc(sizeof(struct tmdc), GFP_KERNEL))) 351 + tmdc = kzalloc(sizeof(*tmdc), GFP_KERNEL); 352 + if (!tmdc) 352 353 return -ENOMEM; 353 354 354 355 tmdc->gameport = gameport;
+1 -1
drivers/input/joystick/turbografx.c
··· 172 172 return; 173 173 } 174 174 175 - tgfx = kzalloc(sizeof(struct tgfx), GFP_KERNEL); 175 + tgfx = kzalloc(sizeof(*tgfx), GFP_KERNEL); 176 176 if (!tgfx) { 177 177 printk(KERN_ERR "turbografx.c: Not enough memory\n"); 178 178 goto err_unreg_pardev;
+1 -1
drivers/input/joystick/twidjoy.c
··· 171 171 int err = -ENOMEM; 172 172 int i; 173 173 174 - twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL); 174 + twidjoy = kzalloc(sizeof(*twidjoy), GFP_KERNEL); 175 175 input_dev = input_allocate_device(); 176 176 if (!twidjoy || !input_dev) 177 177 goto fail1;
+1 -1
drivers/input/joystick/warrior.c
··· 124 124 struct input_dev *input_dev; 125 125 int err = -ENOMEM; 126 126 127 - warrior = kzalloc(sizeof(struct warrior), GFP_KERNEL); 127 + warrior = kzalloc(sizeof(*warrior), GFP_KERNEL); 128 128 input_dev = input_allocate_device(); 129 129 if (!warrior || !input_dev) 130 130 goto fail1;
+2 -2
drivers/input/joystick/xpad.c
··· 1686 1686 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) 1687 1687 return 0; 1688 1688 1689 - xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); 1689 + xpad->led = led = kzalloc(sizeof(*led), GFP_KERNEL); 1690 1690 if (!led) 1691 1691 return -ENOMEM; 1692 1692 ··· 2022 2022 break; 2023 2023 } 2024 2024 2025 - xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); 2025 + xpad = kzalloc(sizeof(*xpad), GFP_KERNEL); 2026 2026 if (!xpad) 2027 2027 return -ENOMEM; 2028 2028
+1 -1
drivers/input/joystick/zhenhua.c
··· 131 131 struct input_dev *input_dev; 132 132 int err = -ENOMEM; 133 133 134 - zhenhua = kzalloc(sizeof(struct zhenhua), GFP_KERNEL); 134 + zhenhua = kzalloc(sizeof(*zhenhua), GFP_KERNEL); 135 135 input_dev = input_allocate_device(); 136 136 if (!zhenhua || !input_dev) 137 137 goto fail1;