[PATCH 3/8] firmware: initialize variables

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Alexander Huemer alexander.huemer at xx.vu
Wed Nov 23 23:41:56 UTC 2011


On Thu, Nov 24, 2011 at 12:07:23AM +0100, Holger Hans Peter Freyther wrote:
> On 11/23/2011 11:59 PM, Alexander Huemer wrote:
> 
> > +++ b/src/target/firmware/layer1/mframe_sched.c
> > @@ -332,7 +332,7 @@ static const struct mframe_sched_item *sched_set_for_task[32] = {
> >  /* encodes a channel number according to 08.58 Chapter 9.3.1 */
> >  uint8_t mframe_task2chan_nr(enum mframe_task mft, uint8_t ts)
> >  {
> > -	uint8_t cbits;
> > +	uint8_t cbits = 0;
> >  
> >  	switch (mft) {
> >  	case MF_TASK_BCCH_NORM:
> 
> uninitialized variables are tricky. In this case it is more the question of
> which enum value is not handled in the switch/case statement (or if the gcc
> fails to look at all values of the enum).
> E.g. a
> 
> default:
>   cbits = 0;
>   BIG_WARNING(mft);
> 
> might be better?
> 
i am a bit unsure about the best way to handle such stuff. default cases
have the drawback that gcc does not tell you any more that enum values
are not handled in the switch. so i try to avoid default cases on enums.




More information about the baseband-devel mailing list