* [PATCH] [media] lmed04: add missing breaks
@ 2014-11-25 11:19 Mauro Carvalho Chehab
2014-11-25 17:10 ` Malcolm Priestley
0 siblings, 1 reply; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2014-11-25 11:19 UTC (permalink / raw)
To: Linux Media Mailing List
Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Malcolm Priestley
drivers/media/usb/dvb-usb-v2/lmedm04.c:828 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
drivers/media/usb/dvb-usb-v2/lmedm04.c:849 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 9f2c5459b73a..99587418f4f0 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -826,6 +826,7 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
break;
}
st->dvb_usb_lme2510_firmware = TUNER_LG;
+ break;
case TUNER_LG:
fw_lme = fw_lg;
ret = request_firmware(&fw, fw_lme, &udev->dev);
@@ -847,6 +848,7 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
break;
}
st->dvb_usb_lme2510_firmware = TUNER_LG;
+ break;
case TUNER_LG:
fw_lme = fw_c_lg;
ret = request_firmware(&fw, fw_lme, &udev->dev);
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [media] lmed04: add missing breaks
2014-11-25 11:19 [PATCH] [media] lmed04: add missing breaks Mauro Carvalho Chehab
@ 2014-11-25 17:10 ` Malcolm Priestley
2014-11-25 18:00 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 4+ messages in thread
From: Malcolm Priestley @ 2014-11-25 17:10 UTC (permalink / raw)
To: linux-media; +Cc: Mauro Carvalho Chehab
On 25/11/14 11:19, Mauro Carvalho Chehab wrote:
> drivers/media/usb/dvb-usb-v2/lmedm04.c:828 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
> drivers/media/usb/dvb-usb-v2/lmedm04.c:849 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
>
> diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
> index 9f2c5459b73a..99587418f4f0 100644
> --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
> +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
> @@ -826,6 +826,7 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
> break;
> }
> st->dvb_usb_lme2510_firmware = TUNER_LG;
> + break;
> case TUNER_LG:
> fw_lme = fw_lg;
> ret = request_firmware(&fw, fw_lme, &udev->dev);
> @@ -847,6 +848,7 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
> break;
> }
> st->dvb_usb_lme2510_firmware = TUNER_LG;
> + break;
> case TUNER_LG:
> fw_lme = fw_c_lg;
> ret = request_firmware(&fw, fw_lme, &udev->dev);
>
The break is not missing it's three lines above.
All these switches are fall through until it finds firmware the user has.
The switch comes into play when the firmware needs to changed.
Malcolm
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [media] lmed04: add missing breaks
2014-11-25 17:10 ` Malcolm Priestley
@ 2014-11-25 18:00 ` Mauro Carvalho Chehab
2014-11-25 20:45 ` Malcolm Priestley
0 siblings, 1 reply; 4+ messages in thread
From: Mauro Carvalho Chehab @ 2014-11-25 18:00 UTC (permalink / raw)
To: Malcolm Priestley; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab
Em Tue, 25 Nov 2014 17:10:00 +0000
Malcolm Priestley <malcolmpriestley@gmail.com> escreveu:
> On 25/11/14 11:19, Mauro Carvalho Chehab wrote:
> > drivers/media/usb/dvb-usb-v2/lmedm04.c:828 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
> > drivers/media/usb/dvb-usb-v2/lmedm04.c:849 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
> >
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> >
> > diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
> > index 9f2c5459b73a..99587418f4f0 100644
> > --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
> > +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
> > @@ -826,6 +826,7 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
> > break;
> > }
> > st->dvb_usb_lme2510_firmware = TUNER_LG;
> > + break;
> > case TUNER_LG:
> > fw_lme = fw_lg;
> > ret = request_firmware(&fw, fw_lme, &udev->dev);
> > @@ -847,6 +848,7 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
> > break;
> > }
> > st->dvb_usb_lme2510_firmware = TUNER_LG;
> > + break;
> > case TUNER_LG:
> > fw_lme = fw_c_lg;
> > ret = request_firmware(&fw, fw_lme, &udev->dev);
> >
> The break is not missing it's three lines above.
>
> All these switches are fall through until it finds firmware the user has.
>
> The switch comes into play when the firmware needs to changed.
Oh! Well, I was so sure that the patch was right that I merged it already.
My bad.
Anyway, smatch complains if dvb_usb_lme2510_firmware is rewritten,
and that bothers people that use static analyzers. So, IMO, the best
is to rework the code in order to:
- document that the breaks should not be used there;
- remove smatch warning.
What do you think about the following patch?
Revert "[media] lmed04: add missing breaks"
According with Malcolm, the missing breaks are intentional.
So, let's revert commit d442b15fb4deb2b5d516e2dae1f569b1d5472399,
add some comments to document it and fix the two smatch warnings:
drivers/media/usb/dvb-usb-v2/lmedm04.c:828 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
drivers/media/usb/dvb-usb-v2/lmedm04.c:850 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
using a different strategy to avoid reassign values to
st->dvb_usb_lme2510_firmware.
Requested-by: Malcolm Priestley <malcolmpriestley@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 99587418f4f0..994de53a574b 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -817,21 +817,22 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
case 0x1122:
switch (st->dvb_usb_lme2510_firmware) {
default:
- st->dvb_usb_lme2510_firmware = TUNER_S0194;
case TUNER_S0194:
fw_lme = fw_s0194;
ret = request_firmware(&fw, fw_lme, &udev->dev);
if (ret == 0) {
+ st->dvb_usb_lme2510_firmware = TUNER_S0194;
cold = 0;
break;
}
- st->dvb_usb_lme2510_firmware = TUNER_LG;
- break;
+ /* fall through */
case TUNER_LG:
fw_lme = fw_lg;
ret = request_firmware(&fw, fw_lme, &udev->dev);
- if (ret == 0)
+ if (ret == 0) {
+ st->dvb_usb_lme2510_firmware = TUNER_LG;
break;
+ }
st->dvb_usb_lme2510_firmware = TUNER_DEFAULT;
break;
}
@@ -839,27 +840,30 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
case 0x1120:
switch (st->dvb_usb_lme2510_firmware) {
default:
- st->dvb_usb_lme2510_firmware = TUNER_S7395;
case TUNER_S7395:
fw_lme = fw_c_s7395;
ret = request_firmware(&fw, fw_lme, &udev->dev);
if (ret == 0) {
+ st->dvb_usb_lme2510_firmware = TUNER_S7395;
cold = 0;
break;
}
- st->dvb_usb_lme2510_firmware = TUNER_LG;
- break;
+ /* fall through */
case TUNER_LG:
fw_lme = fw_c_lg;
ret = request_firmware(&fw, fw_lme, &udev->dev);
- if (ret == 0)
+ if (ret == 0) {
+ st->dvb_usb_lme2510_firmware = TUNER_LG;
break;
- st->dvb_usb_lme2510_firmware = TUNER_S0194;
+ }
+ /* fall through */
case TUNER_S0194:
fw_lme = fw_c_s0194;
ret = request_firmware(&fw, fw_lme, &udev->dev);
- if (ret == 0)
+ if (ret == 0) {
+ st->dvb_usb_lme2510_firmware = TUNER_S0194;
break;
+ }
st->dvb_usb_lme2510_firmware = TUNER_DEFAULT;
cold = 0;
break;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [media] lmed04: add missing breaks
2014-11-25 18:00 ` Mauro Carvalho Chehab
@ 2014-11-25 20:45 ` Malcolm Priestley
0 siblings, 0 replies; 4+ messages in thread
From: Malcolm Priestley @ 2014-11-25 20:45 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: Linux Media Mailing List, Mauro Carvalho Chehab
On 25/11/14 18:00, Mauro Carvalho Chehab wrote:
> Em Tue, 25 Nov 2014 17:10:00 +0000
> Malcolm Priestley <malcolmpriestley@gmail.com> escreveu:
>
>> On 25/11/14 11:19, Mauro Carvalho Chehab wrote:
>>> drivers/media/usb/dvb-usb-v2/lmedm04.c:828 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
>>> drivers/media/usb/dvb-usb-v2/lmedm04.c:849 lme_firmware_switch() warn: missing break? reassigning 'st->dvb_usb_lme2510_firmware'
>>>
>>> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
>>>
>>> diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
>>> index 9f2c5459b73a..99587418f4f0 100644
>>> --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
>>> +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
>>> @@ -826,6 +826,7 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
>>> break;
>>> }
>>> st->dvb_usb_lme2510_firmware = TUNER_LG;
>>> + break;
>>> case TUNER_LG:
>>> fw_lme = fw_lg;
>>> ret = request_firmware(&fw, fw_lme, &udev->dev);
>>> @@ -847,6 +848,7 @@ static const char *lme_firmware_switch(struct dvb_usb_device *d, int cold)
>>> break;
>>> }
>>> st->dvb_usb_lme2510_firmware = TUNER_LG;
>>> + break;
>>> case TUNER_LG:
>>> fw_lme = fw_c_lg;
>>> ret = request_firmware(&fw, fw_lme, &udev->dev);
>>>
>> The break is not missing it's three lines above.
>>
>> All these switches are fall through until it finds firmware the user has.
>>
>> The switch comes into play when the firmware needs to changed.
>
> Oh! Well, I was so sure that the patch was right that I merged it already.
> My bad.
>
> Anyway, smatch complains if dvb_usb_lme2510_firmware is rewritten,
> and that bothers people that use static analyzers. So, IMO, the best
> is to rework the code in order to:
> - document that the breaks should not be used there;
> - remove smatch warning.
>
> What do you think about the following patch?
Fine
Acked-by: Malcolm Priestley <tvboxspy@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-25 20:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-25 11:19 [PATCH] [media] lmed04: add missing breaks Mauro Carvalho Chehab
2014-11-25 17:10 ` Malcolm Priestley
2014-11-25 18:00 ` Mauro Carvalho Chehab
2014-11-25 20:45 ` Malcolm Priestley
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.