Manu Abraham wrote: > Allan Stirling wrote: > > p_program_descriptor->program_number = > > ((p_program_descriptor->program_number | buf[pos + 0]) << 8) | buf[pos + 1]; > > > >Doesn't look quite right. Why do we care what the program_number is > >before it's been parsed? > > Hmm, that is required because buf is 8 bits. All what i do is, get buf > into program_number and shift program_number to the left by 8. > > >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 problem would be solved, if program_number is initialized to 0 just > before reading in from the buffer. It still would be hard to read. How about: p_program_descriptor->program_number = ((uint16_t) buf[pos] << 8) | buf[pos + 1]; Johannes