Messages in this thread | | | Subject | Re: [PATCH] leds: ti-lmu-common: Fix coccinelle issue in TI LMU | From | Dan Murphy <> | Date | Tue, 27 Aug 2019 08:37:14 -0500 |
| |
Jacek
On 8/26/19 2:34 PM, Jacek Anaszewski wrote: > Dan, > > On 8/26/19 4:53 PM, Dan Murphy wrote: >> Jacek >> >> On 8/24/19 10:18 AM, Jacek Anaszewski wrote: >>> Hi Dan, >>> >>> Thank you for the patch. >>> >>> On 8/23/19 9:55 PM, Dan Murphy wrote: >>>> Fix the coccinelle issues found in the TI LMU common code >>>> >>>> drivers/leds/leds-ti-lmu-common.c:97:20-29: WARNING: Unsigned >>>> expression compared with zero: ramp_down < 0 >>>> drivers/leds/leds-ti-lmu-common.c:97:5-12: WARNING: Unsigned >>>> expression compared with zero: ramp_up < 0 >>> Wouldn't it make more sense to remove those pointless checks? >>> Clearly a correct index of an array cannot be negative. >>> Looking at the code I would make more int -> unsigned int conversions: >>> >>> - ramp_table should be unsigned int >>> - ti_lmu_common_convert_ramp_to_index should return unsigned int >>> >> Yeah I was going to just remove the code but when I was writing the >> original code my intent was >> >> to extend the ramp call to allow other TI LMU driver to pass in the >> device specific ramp table. >> >> But since I don't currently have any devices on my plate that require >> that I can just remove the code as well > You don't need to remove, just do the conversions I proposed. > Unless it introduces some other problems I am currently not aware of. > Well just converting those two would/did not fix the issue.
But actually there is only 1 possibility that could happen if the convert function returns -EINVAL
So the check should be
if (ramp_up == -EINVAL || ramp_down == -EINVAL)
Because ramp_up/down should never be less then zero otherwise.
Dan
| |