Clean with clang analyzer

Change-Id: I4897b3a88795d76f4ac7e6f788a7e6d19397dbfd
This commit is contained in:
Émilie Feral
2017-03-20 15:16:12 +01:00
parent 40707f2d6f
commit 680c84e413
8 changed files with 48 additions and 29 deletions

View File

@@ -24,7 +24,7 @@ void CalculationSelectableTableView::scrollToCell(int i, int j) {
if (dataSource()->rowHeight(j) > bounds().height()) {
KDCoordinate contentOffsetX = contentOffset().x();
KDCoordinate contentOffsetY = contentOffset().y();
if (contentOffset().y() > dataSource()->cumulatedHeightFromIndex(j) && contentOffset().y() > dataSource()->cumulatedHeightFromIndex(j+1)) {
if (contentOffsetY > dataSource()->cumulatedHeightFromIndex(j) && contentOffsetY > dataSource()->cumulatedHeightFromIndex(j+1)) {
// Let's scroll the tableView to align the top of the cell to the top
contentOffsetY = dataSource()->cumulatedHeightFromIndex(j);
} else {
@@ -47,15 +47,13 @@ void CalculationSelectableTableView::scrollToSubviewOfTypeOfCellAtLocation(Histo
}
/* Main part of the scroll */
KDCoordinate contentOffsetX = contentOffset().x();
KDCoordinate contentOffsetY = contentOffset().y();
KDCoordinate contentOffsetY = dataSource()->cumulatedHeightFromIndex(j+1) - maxContentHeightDisplayableWithoutScrolling();
if (subviewType == HistoryViewCell::SubviewType::Input) {
if (j == 0) {
contentOffsetY = 0;
} else {
contentOffsetY = dataSource()->cumulatedHeightFromIndex(j);
}
} else {
contentOffsetY = dataSource()->cumulatedHeightFromIndex(j+1) - maxContentHeightDisplayableWithoutScrolling();
}
/* For the same reason, we have to rehighlight the new history view cell and
* inform the delegate which history view cell is highlighted even if the

View File

@@ -47,7 +47,7 @@ void ValuesController::willDisplayCellAtLocation(HighlightCell * cell, int i, in
FunctionTitleCell * myFunctionCell = (FunctionTitleCell *)cell;
CartesianFunction * function = functionAtColumn(i);
char bufferName[6] = {0, 0, '(', 'x', ')', 0};
const char * name = bufferName;
const char * name = nullptr;
if (isDerivativeColumn(i)) {
bufferName[0] = *function->name();
bufferName[1] = '\'';

View File

@@ -65,10 +65,8 @@ int Store::closestVerticalDot(int direction, float x) {
// Compare with the mean dot
if (m_xMin <= meanOfColumn(0) && meanOfColumn(0) <= m_xMax &&
(fabsf(meanOfColumn(0) - x) < fabsf(nextX - x)) &&
((meanOfColumn(1) - yValueForXValue(meanOfColumn(0)) >= 0) == (direction > 0))) {
((meanOfColumn(1) - yValueForXValue(meanOfColumn(0)) >= 0) == (direction > 0))) {
if (nextX != meanOfColumn(0) || ((nextY - meanOfColumn(1) >= 0) == (direction > 0))) {
nextX = meanOfColumn(0);
nextY = meanOfColumn(1);
selectedDot = m_numberOfPairs;
}
}
@@ -105,7 +103,6 @@ int Store::nextDot(int direction, int dot) {
(m_numberOfPairs != dot) &&
(meanOfColumn(0) >= x)) {
if (meanOfColumn(0) != x || (x > dot)) {
nextX = meanOfColumn(0);
selectedDot = m_numberOfPairs;
}
}

View File

@@ -178,7 +178,7 @@ void HistogramController::reloadBannerView() {
strlcpy(buffer, legend, legendLength+1);
numberOfChar += legendLength;
float frequency = size/m_store->sumOfColumn(1);
numberOfChar += Complex::convertFloatToText(frequency, buffer+legendLength, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
Complex::convertFloatToText(frequency, buffer+numberOfChar, Complex::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits);
m_bannerView.setLegendAtIndex(buffer, 5);
}

View File

@@ -47,17 +47,37 @@ Expression * BinaryOperation::privateEvaluate(Context& context, AngleUnit angleU
return nullptr;
}
Expression * result = nullptr;
if (leftOperandEvalutation->type() == Type::Complex && rightOperandEvalutation->type() == Type::Complex) {
result = evaluateOnComplex((Complex *)leftOperandEvalutation, (Complex *)rightOperandEvalutation, context, angleUnit);
}
if (leftOperandEvalutation->type() == Type::Complex && rightOperandEvalutation->type() == Type::Matrix) {
result = evaluateOnComplexAndMatrix((Complex *)leftOperandEvalutation, (Matrix *)rightOperandEvalutation, context, angleUnit);
}
if (leftOperandEvalutation->type() == Type::Matrix && rightOperandEvalutation->type() == Type::Complex) {
result = evaluateOnMatrixAndComplex((Matrix *)leftOperandEvalutation, (Complex *)rightOperandEvalutation, context, angleUnit);
}
if (leftOperandEvalutation->type() == Type::Matrix && rightOperandEvalutation->type() == Type::Matrix) {
result = evaluateOnMatrices((Matrix *)leftOperandEvalutation, (Matrix *)rightOperandEvalutation, context, angleUnit);
switch (leftOperandEvalutation->type()) {
case Type::Complex:
{
switch (rightOperandEvalutation->type()) {
case Type::Complex:
result = evaluateOnComplex((Complex *)leftOperandEvalutation, (Complex *)rightOperandEvalutation, context, angleUnit);
break;
case Type::Matrix:
result = evaluateOnComplexAndMatrix((Complex *)leftOperandEvalutation, (Matrix *)rightOperandEvalutation, context, angleUnit);
break;
default:
break;
}
}
break;
case Type::Matrix:
{
switch (rightOperandEvalutation->type()) {
case Type::Complex:
result = evaluateOnMatrixAndComplex((Matrix *)leftOperandEvalutation, (Complex *)rightOperandEvalutation, context, angleUnit);
break;
case Type::Matrix:
result = evaluateOnMatrices((Matrix *)leftOperandEvalutation, (Matrix *)rightOperandEvalutation, context, angleUnit);
break;
default:
break;
}
}
break;
default:
break;
}
delete leftOperandEvalutation;
delete rightOperandEvalutation;

View File

@@ -283,8 +283,8 @@ Expression * Matrix::createInverse(Context& context, AngleUnit angleUnit) const
}
}
Expression ** operands = (Expression **)malloc(numberOfOperands()*sizeof(Expression *));
for (int i = 0; i < numberOfRows(); i++) {
for (int j = 0; j < numberOfColumns(); j++) {
for (int i = 0; i < dim; i++) {
for (int j = 0; j < dim; j++) {
operands[i*dim+j] = new Complex(Complex::Float(inv[i][j+dim]));
}
}

View File

@@ -43,11 +43,15 @@ Expression * Opposite::privateEvaluate(Context& context, AngleUnit angleUnit) co
return nullptr;
}
Expression * result = nullptr;
if (operandEvalutation->type() == Type::Complex) {
result = new Complex(Complex::Cartesian(-((Complex *)operandEvalutation)->a(), -((Complex *)operandEvalutation)->b()));
}
if (operandEvalutation->type() == Type::Matrix) {
result = evaluateOnMatrix((Matrix *)operandEvalutation, context, angleUnit);
switch (operandEvalutation->type()) {
case Type::Complex:
result = new Complex(Complex::Cartesian(-((Complex *)operandEvalutation)->a(), -((Complex *)operandEvalutation)->b()));
break;
case Type::Matrix:
result = evaluateOnMatrix((Matrix *)operandEvalutation, context, angleUnit);
break;
default:
break;
}
delete operandEvalutation;
return result;

View File

@@ -14,7 +14,7 @@ ExpressionMatch::ExpressionMatch() {
ExpressionMatch::ExpressionMatch(const Expression ** expressions, int numberOfExpressions) {
m_numberOfExpressions = numberOfExpressions;
m_expressions = (const Expression**) malloc(m_numberOfExpressions * sizeof(ExpressionMatch*));
m_expressions = (const Expression**) malloc(m_numberOfExpressions * sizeof(Expression*));
for (int i(0); i<numberOfExpressions; i++) {
m_expressions[i] = expressions[i];
}