you know what, fread returns number of elements, not bytes

This commit is contained in:
Pauli Oikkonen 2020-11-13 20:59:58 +02:00
parent c89477bb41
commit 4deed04eb9
2 changed files with 8 additions and 8 deletions

View file

@ -92,8 +92,8 @@ int process_rdcosts(FILE *in, FILE *out)
if (n_read == 0) {
break;
}
if (feof(in) || n_read < sizeof(uint32_t) * 2) {
fprintf(stderr, "Unexpected EOF when reading header, managed still to read %u bytes\n", n_read);
if (feof(in) || n_read < 2) {
fprintf(stderr, "Unexpected EOF when reading header, managed still to read %u u32's\n", n_read);
rv = 1;
goto out;
}
@ -105,8 +105,8 @@ int process_rdcosts(FILE *in, FILE *out)
size_sqrt = 1 << (ilog2(size) >> 1);
n_read = fread(buf, sizeof(int16_t), size, in);
if (n_read != size * sizeof(int16_t)) {
fprintf(stderr, "Unexpected EOF when reading block, managed still to read %u bytes\n", n_read);
if (n_read != size) {
fprintf(stderr, "Unexpected EOF when reading block, managed still to read %u i16's\n", n_read);
rv = 1;
goto out;
}

View file

@ -87,8 +87,8 @@ int process_rdcosts(FILE *in, FILE *out, const double *mat)
if (n_read == 0) {
break;
}
if (feof(in) || n_read < sizeof(uint32_t) * 2) {
fprintf(stderr, "Unexpected EOF when reading header, managed still to read %u bytes\n", n_read);
if (feof(in) || n_read < 2) {
fprintf(stderr, "Unexpected EOF when reading header, managed still to read %u u32's\n", n_read);
rv = 1;
goto out;
}
@ -101,8 +101,8 @@ int process_rdcosts(FILE *in, FILE *out, const double *mat)
size_sqrt = 1 << (ilog2(size) >> 1);
n_read = fread(buf, sizeof(int16_t), size, in);
if (n_read != size * sizeof(int16_t)) {
fprintf(stderr, "Unexpected EOF when reading block, managed still to read %u bytes\n", n_read);
if (n_read != size) {
fprintf(stderr, "Unexpected EOF when reading block, managed still to read %u i16's\n", n_read);
rv = 1;
goto out;
}