Skip to content
Snippets Groups Projects
Commit 8d5dfed5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

udisks: fix off-by-one

Refs #28486.
parent e44289ca
No related branches found
No related tags found
1 merge request!4804udisks: fix off-by-one
Pipeline #427583 passed with stage
in 11 minutes and 59 seconds
......@@ -101,8 +101,12 @@ static int human(uint64_t *i)
{
if (i == 0)
return 0;
unsigned exp = (stdc_bit_width(*i) - 1) / 10;
exp = (exp < ARRAY_SIZE(binary_prefixes)) ? exp : ARRAY_SIZE(binary_prefixes);
if (exp >= ARRAY_SIZE(binary_prefixes))
exp = ARRAY_SIZE(binary_prefixes) - 1;
*i >>= (10 * exp);
return exp;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment