提交 5f3f24fa 编写于 作者: A Alexey Dobriyan 提交者: David S. Miller

[ATM] ambassador,firestream: "-1 >>" is implementation defined

6.5.7(5): The result of E1 >> E2 is E1 right-shifted E2 bit positions.
		...
	If E1 has a signed type and a negative value, the resulting value
	is implementation defined.

So, cast -1 to unsigned type to make result well-defined.

[ Modified to use ~0U based upon recommendation from Al Viro. -DaveM ]
Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 2ee92d46
......@@ -972,7 +972,7 @@ static int make_rate (unsigned int rate, rounding r,
}
case round_up: {
// check all bits that we are discarding
if (man & (-1>>9)) {
if (man & (~0U>>9)) {
man = (man>>(32-9)) + 1;
if (man == (1<<9)) {
// no need to check for round up outside of range
......
......@@ -512,7 +512,7 @@ static unsigned int make_rate (unsigned int rate, int r,
}
case ROUND_UP: {
/* check all bits that we are discarding */
if (man & (-1>>9)) {
if (man & (~0U>>9)) {
man = (man>>(32-9)) + 1;
if (man == (1<<9)) {
/* no need to check for round up outside of range */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册