Fix compiler warnings

This commit is contained in:
N 2020-10-28 14:18:55 -04:00
commit 86ca5062ed
4 changed files with 19 additions and 31 deletions

View file

@ -194,7 +194,7 @@ void CHistoryCollector::AddCloseBraceToHistory()
void CHistoryCollector::EnclosePrecInversionBrackets() void CHistoryCollector::EnclosePrecInversionBrackets()
{ {
// Top of the Opnd starts index or 0 is nothing is in top // Top of the Opnd starts index or 0 if nothing is in top
int ichStart = (m_curOperandIndex > 0) ? m_operandIndices[m_curOperandIndex - 1] : 0; int ichStart = (m_curOperandIndex > 0) ? m_operandIndices[m_curOperandIndex - 1] : 0;
InsertSzInEquationSz(CCalcEngine::OpCodeToString(IDC_OPENP), -1, ichStart); InsertSzInEquationSz(CCalcEngine::OpCodeToString(IDC_OPENP), -1, ichStart);
@ -203,7 +203,7 @@ void CHistoryCollector::EnclosePrecInversionBrackets()
bool CHistoryCollector::FOpndAddedToHistory() bool CHistoryCollector::FOpndAddedToHistory()
{ {
return (-1 != m_lastOpStartIndex); return (m_lastOpStartIndex != -1);
} }
// AddUnaryOpToHistory // AddUnaryOpToHistory

View file

@ -610,7 +610,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
} }
// Set the "(=xx" indicator. // Set the "(=xx" indicator.
if (nullptr != m_pCalcDisplay) if (m_pCalcDisplay != nullptr)
{ {
m_pCalcDisplay->SetParenthesisNumber(m_openParenCount >= 0 ? static_cast<unsigned int>(m_openParenCount) : 0); m_pCalcDisplay->SetParenthesisNumber(m_openParenCount >= 0 ? static_cast<unsigned int>(m_openParenCount) : 0);
} }

View file

@ -358,10 +358,9 @@ PNUMBER numtonRadixx(_In_ PNUMBER a, uint32_t radix)
{ {
PNUMBER pnumret = i32tonum(0, BASEX); // pnumret is the number in internal form. PNUMBER pnumret = i32tonum(0, BASEX); // pnumret is the number in internal form.
PNUMBER num_radix = i32tonum(radix, BASEX); PNUMBER num_radix = i32tonum(radix, BASEX);
MANTTYPE* ptrdigit = a->mant; // pointer to digit being worked on.
// Digits are in reverse order, back over them LSD first. // Digits are in reverse order, back over them LSD first.
ptrdigit += a->cdigit - 1; MANTTYPE* ptrdigit = a->mant + a->cdigit - 1; // pointer to digit being worked on.
PNUMBER thisdigit = nullptr; // thisdigit holds the current digit of a PNUMBER thisdigit = nullptr; // thisdigit holds the current digit of a
for (int32_t idigit = 0; idigit < a->cdigit; idigit++) for (int32_t idigit = 0; idigit < a->cdigit; idigit++)
@ -992,8 +991,7 @@ int32_t numtoi32(_In_ PNUMBER pnum, uint32_t radix)
{ {
int32_t lret = 0; int32_t lret = 0;
MANTTYPE* pmant = pnum->mant; MANTTYPE* pmant = pnum->mant + pnum->cdigit - 1;
pmant += pnum->cdigit - 1;
int32_t expt = pnum->exp; int32_t expt = pnum->exp;
for (int32_t length = pnum->cdigit; length > 0 && length + expt > 0; length--) for (int32_t length = pnum->cdigit; length > 0 && length + expt > 0; length--)
@ -1002,9 +1000,10 @@ int32_t numtoi32(_In_ PNUMBER pnum, uint32_t radix)
lret += *(pmant--); lret += *(pmant--);
} }
while (expt-- > 0) while (expt > 0)
{ {
lret *= radix; lret *= radix;
expt--;
} }
lret *= pnum->sign; lret *= pnum->sign;
@ -1050,7 +1049,7 @@ bool stripzeroesnum(_Inout_ PNUMBER pnum, int32_t starting)
if (fstrip) if (fstrip)
{ {
// Remove them. // Remove them.
memmove(pnum->mant, pmant, (int)(cdigits * sizeof(MANTTYPE))); memmove(pnum->mant, pmant, static_cast<int>(cdigits * sizeof(MANTTYPE)));
// And adjust exponent and digit count accordingly. // And adjust exponent and digit count accordingly.
pnum->exp += (pnum->cdigit - cdigits); pnum->exp += (pnum->cdigit - cdigits);
pnum->cdigit = cdigits; pnum->cdigit = cdigits;
@ -1404,11 +1403,9 @@ PNUMBER gcd(_In_ PNUMBER a, _In_ PNUMBER b)
PNUMBER i32factnum(int32_t ini32, uint32_t radix) PNUMBER i32factnum(int32_t ini32, uint32_t radix)
{ {
PNUMBER lret = nullptr; PNUMBER lret = i32tonum(1, radix);
PNUMBER tmp = nullptr; PNUMBER tmp = nullptr;
lret = i32tonum(1, radix);
while (ini32 > 0) while (ini32 > 0)
{ {
tmp = i32tonum(ini32--, radix); tmp = i32tonum(ini32--, radix);
@ -1434,11 +1431,9 @@ PNUMBER i32factnum(int32_t ini32, uint32_t radix)
PNUMBER i32prodnum(int32_t start, int32_t stop, uint32_t radix) PNUMBER i32prodnum(int32_t start, int32_t stop, uint32_t radix)
{ {
PNUMBER lret = nullptr; PNUMBER lret = i32tonum(1, radix);
PNUMBER tmp = nullptr; PNUMBER tmp = nullptr;
lret = i32tonum(1, radix);
while (start <= stop) while (start <= stop)
{ {
if (start) if (start)

View file

@ -408,7 +408,7 @@ void _divnum(PNUMBER* pa, PNUMBER b, uint32_t radix, int32_t precision)
// Build a table of multiplications of the divisor, this is quicker for // Build a table of multiplications of the divisor, this is quicker for
// more than radix 'digits' // more than radix 'digits'
list<PNUMBER> numberList{ i32tonum(0L, radix) }; list<PNUMBER> numberList{ i32tonum(0L, radix) };
for (uint32_t i = 1; i < radix; i++) for (uint32_t i = radix; i > 1; i--)
{ {
PNUMBER newValue = nullptr; PNUMBER newValue = nullptr;
DUPNUM(newValue, numberList.front()); DUPNUM(newValue, numberList.front());
@ -418,12 +418,11 @@ void _divnum(PNUMBER* pa, PNUMBER b, uint32_t radix, int32_t precision)
} }
destroynum(tmp); destroynum(tmp);
int32_t digit;
int32_t cdigits = 0; int32_t cdigits = 0;
while (cdigits++ < thismax && !zernum(rem)) while (cdigits++ < thismax && !zernum(rem))
{ {
digit = radix - 1; uint32_t digit = radix - 1;
PNUMBER multiple = nullptr; PNUMBER multiple = rem;
for (const auto& num : numberList) for (const auto& num : numberList)
{ {
if (!lessnum(rem, num) || !--digit) if (!lessnum(rem, num) || !--digit)
@ -446,7 +445,7 @@ void _divnum(PNUMBER* pa, PNUMBER b, uint32_t radix, int32_t precision)
if (c->mant != ++ptrc) if (c->mant != ++ptrc)
{ {
memmove(c->mant, ptrc, (int)(cdigits * sizeof(MANTTYPE))); memmove(c->mant, ptrc, static_cast<int>(cdigits * sizeof(MANTTYPE)));
} }
// Cleanup table structure // Cleanup table structure
@ -515,12 +514,9 @@ bool equnum(_In_ PNUMBER a, _In_ PNUMBER b)
else else
{ {
// OK the exponents match. // OK the exponents match.
pa = a->mant; pa = a->mant + a->cdigit - 1;
pb = b->mant; pb = b->mant + b->cdigit - 1;
pa += a->cdigit - 1; ccdigits = cdigits = max(a->cdigit, b->cdigit);
pb += b->cdigit - 1;
cdigits = max(a->cdigit, b->cdigit);
ccdigits = cdigits;
// Loop over all digits until we run out of digits or there is a // Loop over all digits until we run out of digits or there is a
// difference in the digits. // difference in the digits.
@ -602,14 +598,11 @@ bool lessnum(_In_ PNUMBER a, _In_ PNUMBER b)
bool zernum(_In_ PNUMBER a) bool zernum(_In_ PNUMBER a)
{ {
int32_t length; MANTTYPE* pcha = a->mant;
MANTTYPE* pcha;
length = a->cdigit;
pcha = a->mant;
// loop over all the digits until you find a nonzero or until you run // loop over all the digits until you find a nonzero or until you run
// out of digits // out of digits
while (length-- > 0) for (auto length = a->cdigit; length > 0; length--)
{ {
if (*pcha++) if (*pcha++)
{ {