DVB: BANDWIDTH_TO_KHZ strangeness

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Adrian Bunk
Date: Sunday, October 14, 2007 - 10:50 am

drivers/media/dvb/frontends/dibx000_common.h contains:

<--  snip  -->

...
#define BANDWIDTH_TO_KHZ(v) ( (v) == BANDWIDTH_8_MHZ  ? 8000 : \
                             (v) == BANDWIDTH_7_MHZ  ? 7000 : \
                             (v) == BANDWIDTH_6_MHZ  ? 6000 : 8000 )
...

<--  snip  -->


Commit b6884a17fc70e979ef34e4b5560988b522bb50a0 added to both of 
drivers/media/dvb/frontends/dib7000{m,p}.c:

<--  snip  -->

...
        factor = BANDWIDTH_TO_KHZ(ch->u.ofdm.bandwidth);
        if (factor >= 5000)
                factor = 1;
        else
                factor = 6;
...

<--  snip  -->


factor < 5000 is obviously never possible.

drivers/media/dvb/frontends/dib0070.c contains a similar assumption that 
BANDWIDTH_TO_KHZ() could result in values other than {6,7,8}000
(I haven't checked whether there are more such assumptions in other 
places).

Spotted by the Coverity checker.


cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
DVB: BANDWIDTH_TO_KHZ strangeness, Adrian Bunk, (Sun Oct 14, 10:50 am)
Re: [v4l-dvb-maintainer] DVB: BANDWIDTH_TO_KHZ strangeness, Patrick Boettcher, (Mon Oct 22, 8:10 am)
Re: [v4l-dvb-maintainer] DVB: BANDWIDTH_TO_KHZ strangeness, Mauro Carvalho Chehab, (Mon Oct 22, 11:29 am)
Re: [v4l-dvb-maintainer] DVB: BANDWIDTH_TO_KHZ strangeness, Mauro Carvalho Chehab, (Mon Oct 22, 1:02 pm)