Fix integer overflow in progress count.

This commit is contained in:
Vreixo Formoso 2007-12-29 22:21:11 +01:00
parent 7e66fe43ce
commit d9c9aea0c5
1 changed files with 7 additions and 5 deletions

View File

@ -964,15 +964,17 @@ int iso_write(Ecma119Image *target, void *buf, size_t count)
return ISO_WRITE_ERROR;
}
if (ret > 0){
unsigned int kbw = (unsigned int) target->bytes_written >> 10;
unsigned int kbt = (unsigned int) target->total_size >> 10;
int percent = (kbw * 100) / kbt;
target->bytes_written += count;
{
int percent = (target->bytes_written * 100) / target->total_size;
/* only report in 5% chunks */
if (percent >= target->percent_written + 5) {
iso_msg_debug(target->image, "Processed %u of %u KB (%d %%)",
(unsigned int) target->bytes_written >> 10,
(unsigned int) target->total_size >> 10, percent);
kbw, kbt, percent);
target->percent_written = percent;
}
}