{
while (len > 0) {
ssize_t bytes_read = input_func(userdata, buf, len);
- assert(bytes_read <= len);
+ assert(bytes_read <= (ssize_t)len);
// TODO: We need better error handling here. setjmp()/longjmp()
// should hopefully do the trick, but we need to take care for
unsigned code = read_bits(source, 1);
int i = 0;
- while (code > table->maxcode[i] || table->maxcode[i] == -1) {
+ while (table->maxcode[i] == -1 || code > (unsigned)table->maxcode[i]) {
possibly_refill(source, 1);
code = (code << 1) | read_bits(source, 1);
++i;
(*source->input_func)(source->userdata,
source->bytes + source->bytes_available,
bytes_to_read);
- assert(bytes_read <= bytes_to_read);
+ assert(bytes_read <= (ssize_t)bytes_to_read);
assert(bytes_read >= (ssize_t)-1);
// TODO: We need better error handling here. setjmp()/longjmp()
struct bit_source source;
init_bit_source(&source, custom_read, &ud);
- for (int i = 0; i < sizeof(bytes) * 8 / 6; ++i) {
+ for (unsigned i = 0; i < sizeof(bytes) * 8 / 6; ++i) {
possibly_refill(&source, 6);
unsigned ret = read_bits(&source, 6);
assert(ret == 0x2a);
struct bit_source source;
init_bit_source(&source, custom_read_slow, &ud);
- for (int i = 0; i < sizeof(bytes) * 8 / 6; ++i) {
+ for (unsigned i = 0; i < sizeof(bytes) * 8 / 6; ++i) {
possibly_refill(&source, 6);
unsigned ret = read_bits(&source, 6);
assert(ret == 0x2a);
size_t bytes_read = 0;
size_t bytes_written = 0;
- while (len - bytes_read >= 0) {
+ while (bytes_read < len) {
// Find the first marker byte in the rest of the stream.
const uint8_t* ptr = memchr(src, MARKER_CHAR, len - bytes_read);
if (ptr == NULL) {
{
// Standard NR LCG (we avoid rand() to get consistent behavior across platforms).
uint32_t seed = 1234;
- for (int i = 0; i < len; ++i) {
+ for (unsigned i = 0; i < len; ++i) {
seed = seed * 1664525 + 1013904223;
uint8_t byte = (uint8_t)(seed & 0xff);
if (byte != 0xff) {
struct timeval start, now;
gettimeofday(&start, NULL);
- for (int i = 0; i < num_runs; ++i) {
+ for (unsigned i = 0; i < num_runs; ++i) {
int ret = unstuff(dst, src, len);
assert(ret != -1);
}