Skip to content

Commit

Permalink
Eliminate some -Wabsolute-value compiler warnings
Browse files Browse the repository at this point in the history
sizeField() returns a sqInt.
sqInt is 64bits long on 64bits images.
Taking abs(sqInt) will truncate the size to 32bits.

That's probably benign because the size will rarely exceed 2^31, so we effectively truncate nothing.
But we have a correct way to take absolute value of sqInt (SQABS) and long (labs) so let's just use them and eliminate the false positive warnings.
  • Loading branch information
nicolas-cellier-aka-nice committed Jul 8, 2016
1 parent 034b14a commit b2ed57a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions platforms/Cross/plugins/IA32ABI/dax64business.h
Expand Up @@ -28,7 +28,7 @@
sqInt arg = argVector[i + 1];
if (objIsAlien(arg) && (sizeField(arg) != 0))
/* Direct or indirect Alien. */
size += RoundUpPowerOfTwo(abs(sizeField(arg)), 8);
size += RoundUpPowerOfTwo(SQABS(sizeField(arg)), 8);
else if (interpreterProxy->isFloatObject(arg))
size += sizeof(double);
else
Expand All @@ -42,7 +42,7 @@
sqInt arg = argVector[i];
if (objIsAlien(arg) && (sizeField(arg) != 0))
/* Direct or indirect Alien. */
size += RoundUpPowerOfTwo(abs(sizeField(arg)), 8);
size += RoundUpPowerOfTwo(SQABS(sizeField(arg)), 8);
else if (interpreterProxy->isFloatObject(arg))
size += sizeof(double);
else
Expand Down Expand Up @@ -87,7 +87,7 @@
if ((size = sizeField(arg)) == 0) /* Pointer Alien. */
size = argByteSize = sizeof(void *);
else /* Direct or indirect Alien. */
argByteSize = abs(size);
argByteSize = labs(size);
if ((argByteSize <= sizeof(long)) && (nextReg < NUM_REG_ARGS)) {
regs[nextReg++] = *(long*)startOfDataWithSize(arg, size);
}
Expand Down Expand Up @@ -129,7 +129,7 @@
if ((size = sizeField(arg)) == 0) /* Pointer Alien. */
size = argByteSize = sizeof(void *);
else /* Direct or indirect Alien. */
argByteSize = abs(size);
argByteSize = labs(size);
if ((argByteSize <= sizeof(long)) && (nextReg < NUM_REG_ARGS)) {
regs[nextReg++] = *(long*)startOfDataWithSize(arg, size);
}
Expand Down Expand Up @@ -188,7 +188,7 @@
size = sizeof(long);
memcpy(startOfDataWithSize(resultMaybeAlien, size),
&r,
min((unsigned)abs(size), sizeof(r)));
min((unsigned long)labs(size), sizeof(r)));
}

return PrimNoErr;

0 comments on commit b2ed57a

Please sign in to comment.