[linux-dvb] Problems with ca_zap

Johannes Stezenbach js at linuxtv.org
Sun Jun 26 21:01:53 CEST 2005


Edgar Toernig wrote:
> Manu Abraham wrote:
> >
> > Allan Stirling wrote:
> > >
> > > If I change this to
> > > 
> > >        p_program_descriptor->program_number =
> > >                ( buf[pos + 0] << 8) | buf[pos + 1];
> > > 
> > 
> > This would be wrong however, since if you left shift an 8 bit buffer by 
> > 8 all you will get is 0.
> 
> The code is fine as long as buf is unsigned.  There's no 8-bit
> arithmetic in C - chars are always expanded to ints.  And btw,
> shifting by the width of the (expanded) left operand is undefined,
> not 0.

You are right, operands of arithmetic operators are
subject to integer type promotion. So the simple code
above is correct.

Thanks for pointing this out,
Johannes




More information about the linux-dvb mailing list