In grib_decode_unsigned_long and so on, when input argument nbits is 32
(which should be supported on 32bit) and in the case
"bitsToRead might now be negative (too many bits read)" happened,
once the value "ret" can overflow 32 bit range, later with
the operation "ret >>= -1 * bitsToRead;", "ret" gets fit in 32 bit value.
So during the calculation of "ret" value, preserve the "ret" value
which is to be carried up on left shift, and the last put back the
carried up value to ret again on right shift.
Note that even on 64 bit, currently when input argument nbit is 64 and
when "too many bits read" happened, grib_decode_unsigned_long and so on
don't behave correctly for now. This change will also fix this issue.
The suggestion patch fixes the following failure on linux 32bit:
# 65 - eccodes_t_bufr_dump_encode_filter # 67 - eccodes_t_bufrdc_ref # 76 - eccodes_t_bufr_filter_unpack_pack