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

[media] ir-sony-decoder: shutup smatch warnings

There are some false-positive warnings produced by smatch:
drivers/media/rc/ir-sony-decoder.c:129 ir_sony_decode() warn: missing break? reassigning 'data->state'
drivers/media/rc/ir-sony-decoder.c:137 ir_sony_decode() warn: missing break? reassigning 'data->state'
drivers/media/rc/ir-sony-decoder.c:165 ir_sony_decode() warn: missing break? reassigning 'data->state'

This is due to the logic used there to detect the need of a break.

While those are false positives, it is easy to get rid of them without
any drawbacks. The side effect is a cleaner function, with is good.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

+14 -14
+14 -14
drivers/media/rc/ir-sony-decoder.c
··· 125 125 126 126 switch (data->count) { 127 127 case 12: 128 - if (!(dev->enabled_protocols & RC_BIT_SONY12)) { 129 - data->state = STATE_INACTIVE; 130 - return 0; 131 - } 128 + if (!(dev->enabled_protocols & RC_BIT_SONY12)) 129 + goto finish_state_machine; 130 + 132 131 device = bitrev8((data->bits << 3) & 0xF8); 133 132 subdevice = 0; 134 133 function = bitrev8((data->bits >> 4) & 0xFE); 135 134 protocol = RC_TYPE_SONY12; 136 135 break; 137 136 case 15: 138 - if (!(dev->enabled_protocols & RC_BIT_SONY15)) { 139 - data->state = STATE_INACTIVE; 140 - return 0; 141 - } 137 + if (!(dev->enabled_protocols & RC_BIT_SONY15)) 138 + goto finish_state_machine; 139 + 142 140 device = bitrev8((data->bits >> 0) & 0xFF); 143 141 subdevice = 0; 144 142 function = bitrev8((data->bits >> 7) & 0xFE); 145 143 protocol = RC_TYPE_SONY15; 146 144 break; 147 145 case 20: 148 - if (!(dev->enabled_protocols & RC_BIT_SONY20)) { 149 - data->state = STATE_INACTIVE; 150 - return 0; 151 - } 146 + if (!(dev->enabled_protocols & RC_BIT_SONY20)) 147 + goto finish_state_machine; 148 + 152 149 device = bitrev8((data->bits >> 5) & 0xF8); 153 150 subdevice = bitrev8((data->bits >> 0) & 0xFF); 154 151 function = bitrev8((data->bits >> 12) & 0xFE); ··· 159 162 scancode = device << 16 | subdevice << 8 | function; 160 163 IR_dprintk(1, "Sony(%u) scancode 0x%05x\n", data->count, scancode); 161 164 rc_keydown(dev, protocol, scancode, 0); 162 - data->state = STATE_INACTIVE; 163 - return 0; 165 + goto finish_state_machine; 164 166 } 165 167 166 168 out: ··· 167 171 data->state, TO_US(ev.duration), TO_STR(ev.pulse)); 168 172 data->state = STATE_INACTIVE; 169 173 return -EINVAL; 174 + 175 + finish_state_machine: 176 + data->state = STATE_INACTIVE; 177 + return 0; 170 178 } 171 179 172 180 static struct ir_raw_handler sony_handler = {