On Fri, 19 May 2006, Manu Abraham wrote: > Trent Piepho wrote: > > Why is there padding in both the xxxx_params structs, and in the union that > > contains them? Same for the xxxx_info structs and the union they are in. If > > you have the padding value in the union, the padding in each of the structs in > > the union isn't necessary. > > > > Well, it was a suggestion from Johannes. pad[32] and pad [128] I think maybe that isn't what he meant. Maybe Johannes can provide reasoning why structures in a union and the union itself all need padding. > > If you write a switch statement like this: > > switch(d) { > > case DVBFE_DELSYS_DVBS: return 1; > > case DVBFE_DELSYS_DSS: return 1; > > case DVBFE_DELSYS_DVBS2: return 1; > > case DVBFE_DELSYS_DVBC: return 1; > > case DVBFE_DELSYS_DVBT: return 1; > > case DVBFE_DELSYS_DVBH: return 1; > > case DVBFE_DELSYS_ATSC: return 1; > > } > > > > You will get a warning message from gcc: > > foo.c:14: warning: enumeration value 'DVBFE_DELSYS_DUMMY' not handled in switch > > > > use default. That will not give you any warnings If you do that, you will lose the ability of gcc to warn you if you forget to handle a case. I do not think the API should force application programmers to use a certain style. Obviously, someone likes this warning or gcc wouldn't have it. > > of (1<<0) and go up. Then all the DUMMY values can be eliminated. The values > > are just arbitrary numbers, there shouldn't be any problem in going the order > > direction. > > > I didn't really understand what you meant. You mean (1 << 31) should > have been the first field ? > But i don't see any pronlem in using the current way, other than a > cosmetic issue, but even in a cosmetic case, we start from 0 and go up > normally, don't we .. ? Like this: enum dvbfe_interleaver { DVBFE_INTERLEAVER_IGNORE = (0 << 0), DVBFE_INTERLEAVER_NATIVE = (1 << 31), DVBFE_INTERLEAVER_INDEPTH = (1 << 30), DVBFE_INTERLEAVER_AUTO = (1 << 29) }; Now the DUMMY value isn't needed. One less symbol is defined, and there is no issuse with warnings on switch statements. No one needs to look at the value of DVBFE_INTERLEAVER_NATIVE, so who will care that it is now (1<<31) instead of (1<<0)? _______________________________________________ linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb