mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Fix integer overflow when computing the progress percentage
This commit is contained in:
parent
a3270063dd
commit
85ca997bf2
4 changed files with 40 additions and 24 deletions
|
|
@ -672,3 +672,22 @@ int lock_unlock(int f)
|
|||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/* muldiv */
|
||||
|
||||
unsigned muldiv(uint64_t v, uint64_t mul, uint64_t div)
|
||||
{
|
||||
if (!div)
|
||||
return 0;
|
||||
|
||||
return (uint32_t)(v * mul / div);
|
||||
}
|
||||
|
||||
unsigned muldiv_upper(uint64_t v, uint64_t mul, uint64_t div)
|
||||
{
|
||||
if (!div)
|
||||
return 0;
|
||||
|
||||
return (uint32_t)((v * mul + div - 1) / div);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue