Skip to content

Instantly share code, notes, and snippets.

@easyaspi314
Created January 27, 2019 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save easyaspi314/392c6f63c738298c6f887a0252916d12 to your computer and use it in GitHub Desktop.
Save easyaspi314/392c6f63c738298c6f887a0252916d12 to your computer and use it in GitHub Desktop.
cppcheck bug
$ cppcheck --enable=style uint128mul.c
Checking uint128mul.c ...
[uint128mul.c:9]: (style) The scope of the variable 'botLo' can be reduced.
typedef struct {
unsigned long long hi, lo;
} uint128_t;
typedef unsigned long long uint64_t;
uint128_t long_multiply(/* split uint128_t */ uint64_t topLo, uint64_t topHi)
{
uint64_t botLo = 0x1234567890ABCDEFULL;
uint64_t retHi;
/* widening multiply */
__asm__("mulq %[botLo]" : "+a" (topLo), "=d" (retHi) : [botLo] "r" (botLo));
if (topHi != 0) {
topHi *= botLo;
}
return (uint128_t) { topLo, topHi };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment