The code is the following:
size_t read (char *data, size_t n)
{
try {
if (mp_progress.get ()) {
mp_progress->set (mp_stream->pos ());
}
size_t n0 = n;
for (const char *rd = 0; n > 0 && (rd = mp_stream->get (1)) != 0; --n) {
*data++ = *rd;
}
if (n0 == n) {
return -1;
} else {
return n0 - n;
}
} catch (tl::Exception &ex) {
m_error = ex.msg ();
m_has_error = true;
return -1;
}
}
The return type of read is size_t, which cannot be negative.
return -1 is therefore equal to return UINT_MAX.
I think throwing an exception is better.