On Fri, Apr 19, 2013 at 4:07 PM, Victor Julien <notifications@github.com>wrote:

> In src/util-streaming-parser.c:
>
> > +{
> > +    StreamingParserCtx *tctx = (StreamingParserCtx *)ctx;
> > +    uint16_t u;
> > +
> > +    if (psize <= tctx->temp_buffer_len) {
> > +        if (psize == 2) {
> > +            *((uint16_t *)ret_input) = tctx->temp_buffer & 0x000000000000FFFF;
> > +        } else if (psize == 4) {
> > +            *((uint32_t *)ret_input) = tctx->temp_buffer & 0x00000000FFFFFFFF;
> > +        } else {
> > +            *((uint64_t *)ret_input) = tctx->temp_buffer & 0xFFFFFFFFFFFFFFFF;
> > +        }
> > +        /* Since a type can't be shifted by a value >= width of the type, we
> > +         * need to split it */
> > +        tctx->temp_buffer = tctx->temp_buffer >> (psize * 8 - 1);
> > +        tctx->temp_buffer = tctx->temp_buffer >> 1;
>
> why shift by 1?
>
>
The comment above explains it actually.  Basically if I want to shift it by
the size of the type, say 32 bits, I can't do it(because the language
doesn't allow).  Hence I first shift it by 31 and then a 1.

-- 
Anoop Saldanha