input: members 'name' and 'phys' of 'struct hid_device' can never be NULL
PATCH 1/1 input: members 'name' and 'phys' of 'struct hid_device' can never be NULL
As they are static members of fix size, there is no need to them.
Signed-off-by Daniel Mack <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Jiri Kosina <[email protected]>
--- drivers/hid/hidraw.c | 14 ++------------ drivers/hid/usbhid/hiddev.c | 18 ++---------------- 2 files changed, 4 insertions(+), 28 deletions(-)
drivers/hid/hidraw.c +2 -12
@@ -395,12 +395,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, }if (_IOC_NR (cmd) ==_IOC_NR (HIDIOCGRAWNAME (0 ))) { -int len; -if (!hid->name) { - ret =0 ; -break ; - } - len =strlen (hid->name) +1 ; +int len =strlen (hid->name) +1 ;if (len >_IOC_SIZE (cmd)) len =_IOC_SIZE (cmd); ret = copy_to_user(user_arg, hid->name, len) ?
@@ -409,12 +404,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, }if (_IOC_NR (cmd) ==_IOC_NR (HIDIOCGRAWPHYS (0 ))) { -int len; -if (!hid->phys) { - ret =0 ; -break ; - } - len =strlen (hid->phys) +1 ; +int len =strlen (hid->phys) +1 ;if (len >_IOC_SIZE (cmd)) len =_IOC_SIZE (cmd); ret = copy_to_user(user_arg, hid->phys, len) ?
drivers/hid/usbhid/hiddev.c +2 -16
@@ -801,14 +801,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)break ;if (_IOC_NR (cmd) ==_IOC_NR (HIDIOCGNAME (0 ))) { -int len; - -if (!hid->name) { - r =0 ; -break ; - } - - len =strlen (hid->name) +1 ; +int len =strlen (hid->name) +1 ;if (len >_IOC_SIZE (cmd)) len =_IOC_SIZE (cmd); r = copy_to_user(user_arg, hid->name, len) ?
@@ -817,14 +810,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }if (_IOC_NR (cmd) ==_IOC_NR (HIDIOCGPHYS (0 ))) { -int len; - -if (!hid->phys) { - r =0 ; -break ; - } - - len =strlen (hid->phys) +1 ; +int len =strlen (hid->phys) +1 ;if (len >_IOC_SIZE (cmd)) len =_IOC_SIZE (cmd); r = copy_to_user(user_arg, hid->phys, len) ?
Signature · 1 line
1.7.1
Jiri Kosina
AppliedQuoted 68 lines · Daniel Mack
As they are static members of fix size, there is no need to them.
Signed-off-by Daniel Mack <[email protected]>Cc Dmitry Torokhov <[email protected]>Cc Jiri Kosina <[email protected]>--- drivers/hid/hidraw.c | 14 ++------------ drivers/hid/usbhid/hiddev.c | 18 ++---------------- 2 files changed, 4 insertions(+), 28 deletions(-)drivers/hid/hidraw.c +2
-12@@ -395,12 +395,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, }if (_IOC_NR (cmd) ==_IOC_NR (HIDIOCGRAWNAME (0 ))) { -int len; -if (!hid->name) { - ret =0 ; -break ; - } - len =strlen (hid->name) +1 ; +int len =strlen (hid->name) +1 ;if (len >_IOC_SIZE (cmd)) len =_IOC_SIZE (cmd); ret = copy_to_user(user_arg, hid->name, len) ?@@ -409,12 +404,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, }if (_IOC_NR (cmd) ==_IOC_NR (HIDIOCGRAWPHYS (0 ))) { -int len; -if (!hid->phys) { - ret =0 ; -break ; - } - len =strlen (hid->phys) +1 ; +int len =strlen (hid->phys) +1 ;if (len >_IOC_SIZE (cmd)) len =_IOC_SIZE (cmd); ret = copy_to_user(user_arg, hid->phys, len) ?drivers/hid/usbhid/hiddev.c +1
-10@@ -801,14 +801,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)break ;if (_IOC_NR (cmd) ==_IOC_NR (HIDIOCGNAME (0 ))) { -int len; - -if (!hid->name) { - r =0 ; -break ; - } - - len =strlen (hid->name) +1 ; +int len =strlen (hid->name) +1 ;if (len >_IOC_SIZE (cmd)) len =_IOC_SIZE (cmd); r = copy_to_user(user_arg, hid->name, len) ?@@ -817,14 +810,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) }if (_IOC_NR (cmd) ==_IOC_NR (HIDIOCGPHYS (0 ))) { -int len; -
drivers/hid/usbhid/hiddev.c static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 816
Quoted 10 lines
drivers/hid/usbhid/hiddev.c +1
-6-if (!hid->phys) { - r =0 ; -break ; - } - - len =strlen (hid->phys) +1 ; +int len =strlen (hid->phys) +1 ;if (len >_IOC_SIZE (cmd)) len =_IOC_SIZE (cmd); r = copy_to_user(user_arg, hid->phys, len) ?
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs