Eldbus: fix potential unsigned int underflow.

Subtracting two unsigned values results in an unsigned value, which means
abs() will have no effect.
This also means that if base is smaller than size, we'll have an
unsigned int underflow.

I did it this way (with the if) because it looked like base might be
smaller than size. However, please remove the if (and don't reinstate
the abs) if this is not the case.
This commit is contained in:
Tom Hacohen 2015-04-22 13:17:28 +01:00
parent 5b5b7113b7
commit 5e4b523d51
1 changed files with 1 additions and 1 deletions

View File

@ -91,7 +91,7 @@ _type_offset(char type, unsigned base)
return base;
if (!(base % size))
return base;
padding = abs(base - size);
padding = (base > size) ? base - size : size - base;
return base + padding;
}