misc: tsl2550: remove redundant initialization to variable r
authorColin Ian King <colin.king@canonical.com>
Tue, 7 Jan 2020 17:52:34 +0000 (17:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jan 2020 14:16:51 +0000 (15:16 +0100)
The variable r is being initialized with a value that is never
read and it is being updated later with a new value. Remove
the redundant initialization and move the declaration into a
deeper code block.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200107175234.121298-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/tsl2550.c

index 09db397..6d71865 100644 (file)
@@ -148,16 +148,14 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
        u16 c0 = count_lut[ch0];
        u16 c1 = count_lut[ch1];
 
-       /*
-        * Calculate ratio.
-        * Note: the "128" is a scaling factor
-        */
-       u8 r = 128;
-
        /* Avoid division by 0 and count 1 cannot be greater than count 0 */
        if (c1 <= c0)
                if (c0) {
-                       r = c1 * 128 / c0;
+                       /*
+                        * Calculate ratio.
+                        * Note: the "128" is a scaling factor
+                        */
+                       u8 r = c1 * 128 / c0;
 
                        /* Calculate LUX */
                        lux = ((c0 - c1) * ratio_lut[r]) / 256;