citra-emu/citra — pull request #353 by xdec (2014-12-28 10:19:47+00:00)
Title: Fix underflow issue with USAD8/USADA8.

This is a fix for an overflow caused by the subtraction between two uint32_t. The compiler was raising a warning:
```
/Volumes/Workspace/Hacking/Repositories/citra.dev/src/core/arm/interpreter/armemu.cpp:6678:38: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
const u8 diff4 = (u8)std::labs( ((u32) ((rn_val >> 24) & 0xFF)) - ((u32) ((rm_val >> 24) & 0xFF)) );
^
/Volumes/Workspace/Hacking/Repositories/citra.dev/src/core/arm/interpreter/armemu.cpp:6678:38: note: remove the call to 'labs' since unsigned values cannot be negative
const u8 diff4 = (u8)std::labs( ((u32) ((rn_val >> 24) & 0xFF)) - ((u32) ((rm_val >> 24) & 0xFF)) );
```

The fix catches this kind of error:
```
#include
#include

int
main(void)
{
unsigned int a = 0;
unsigned int b = 1;
std::cout << std::labs(a - b) << std::endl;
return 0;
}

// Result: 4294967295 instead of 1.
```