Fixes warnings thrown by cpplint.py (#154)

* Fixed cpplint.py [runtime/int] warnings

* Fixed cpplint.py [readability/casting] warnings

* Fixed cpplint.py [readability/namespace] warnings

* Fixed cpplint.py [readability/braces] warnings

* Fixed cpplint.py [whitespace/braces] warnings

* Fixed cpplint.py [runtime/explicit] warnings

* Fixed cpplint.py [runtime/printf] warnings

* Fixed cpplint.py [readability/inheritance] warnings

* Fixed cpplint.py [whitespace/tab] warnings

* Fixed cpplint.py [build/storage_class] warnings

* Fixed cpplint.py [readability/multiline_comment] warnings

* Fixed cpplint.py [whitespace/semicolon] warnings

* Fixed cpplint.py [readability/check] warnings

* Fixed cpplint.py [runtime/arrays] warnings

* Ran format.py
This commit is contained in:
Tyler Veness
2016-07-10 17:47:44 -07:00
committed by Peter Johnson
parent e44a6e227a
commit 0cb288ffba
141 changed files with 670 additions and 626 deletions

View File

@@ -133,9 +133,8 @@ int AxisCamera::CopyJPEG(char** destImage, unsigned int& destImageSize,
if (m_imageData.size() == 0) return 0; // if no source image
if (destImageBufferSize <
m_imageData.size()) // if current destination buffer too small
{
// if current destination buffer too small
if (destImageBufferSize < m_imageData.size()) {
if (*destImage != nullptr) delete[] * destImage;
destImageBufferSize = m_imageData.size() + kImageBufferAllocationIncrement;
*destImage = new char[destImageBufferSize];
@@ -148,7 +147,7 @@ int AxisCamera::CopyJPEG(char** destImage, unsigned int& destImageSize,
std::copy(m_imageData.begin(), m_imageData.end(), *destImage);
destImageSize = m_imageData.size();
;
return 1;
}

View File

@@ -45,8 +45,7 @@ void SetDebugFlag(DebugOutputType flag) { dprintfFlag = flag; }
*
* @param tempString The format string.
*/
void dprintf(const char* tempString, ...) /* Variable argument list */
{
void dprintf(const char* tempString, ...) {
va_list args; /* Input argument list */
int line_number; /* Line number passed in argument */
int type;
@@ -166,7 +165,7 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
* @return The normalized position from -1 to +1
*/
double RangeToNormalized(double position, int range) {
return (((position * 2.0) / (double)range) - 1.0);
return position * 2.0 / static_cast<double>(range) - 1.0;
}
/**
@@ -179,11 +178,11 @@ double RangeToNormalized(double position, int range) {
*/
float NormalizeToRange(float normalizedValue, float minRange, float maxRange) {
float range = maxRange - minRange;
float temp = (float)((normalizedValue / 2.0) + 0.5) * range;
float temp = static_cast<float>(normalizedValue / 2.0 + 0.5) * range;
return (temp + minRange);
}
float NormalizeToRange(float normalizedValue) {
return (float)((normalizedValue / 2.0) + 0.5);
return static_cast<float>(normalizedValue / 2.0 + 0.5);
}
/**
@@ -274,7 +273,8 @@ void panInit(double period) {
void panForTarget(Servo* panServo) { panForTarget(panServo, 0.0); }
void panForTarget(Servo* panServo, double sinStart) {
float normalizedSinPosition = (float)SinPosition(nullptr, sinStart);
float normalizedSinPosition =
static_cast<float>(SinPosition(nullptr, sinStart));
float newServoPosition = NormalizeToRange(normalizedSinPosition);
panServo->Set(newServoPosition);
// ShowActivity ("pan x: normalized %f newServoPosition = %f" ,
@@ -295,8 +295,8 @@ void panForTarget(Servo* panServo, double sinStart) {
**/
int processFile(char* inputFile, char* outputString, int lineNumber) {
FILE* infile;
const int stringSize = 80; // max size of one line in file
char inputStr[stringSize];
const int kStringSize = 80; // max size of one line in file
char inputStr[kStringSize];
inputStr[0] = '\0';
int lineCount = 0;
@@ -308,16 +308,16 @@ int processFile(char* inputFile, char* outputString, int lineNumber) {
}
while (!std::feof(infile)) {
if (std::fgets(inputStr, stringSize, infile) != nullptr) {
if (std::fgets(inputStr, kStringSize, infile) != nullptr) {
// Skip empty lines
if (emptyString(inputStr)) continue;
// Skip comment lines
if (inputStr[0] == '#' || inputStr[0] == '!') continue;
lineCount++;
if (lineNumber == 0)
if (lineNumber == 0) {
continue;
else {
} else {
if (lineCount == lineNumber) break;
}
}

View File

@@ -157,7 +157,7 @@ bool BinaryImage::ParticleMeasurement(int particleNumber,
double resultDouble;
bool success =
ParticleMeasurement(particleNumber, whatToMeasure, &resultDouble);
*result = (int)resultDouble;
*result = static_cast<int>(resultDouble);
return success;
}
@@ -184,7 +184,7 @@ bool BinaryImage::ParticleMeasurement(int particleNumber,
// Normalizes to [-1,1]
double BinaryImage::NormalizeFromRange(double position, int range) {
return (position * 2.0 / (double)range) - 1.0;
return position * 2.0 / static_cast<double>(range) - 1.0;
}
/**

View File

@@ -57,8 +57,7 @@ int frcDispose(void* object) { return imaqDispose(object); }
* @return On success: 1. On failure: 0. To get extended error information, call
* GetLastError().
*/
int frcDispose(const char* functionName, ...) /* Variable argument list */
{
int frcDispose(const char* functionName, ...) {
va_list disposalPtrList; /* Input argument list */
void* disposalPtr; /* For iteration */
int success, returnValue = 1;
@@ -281,7 +280,9 @@ ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
ColorMode mode, Image* mask) {
return imaqColorHistogram2((Image*)image, numClasses, mode, nullptr, mask);
return imaqColorHistogram2(
const_cast<Image*>(reinterpret_cast<const Image*>(image)), numClasses,
mode, nullptr, mask);
}
/**
@@ -451,14 +452,14 @@ int frcParticleAnalysis(Image* image, int particleNumber,
if (!success) {
return success;
}
par->center_mass_x = (int)returnDouble; // pixel
par->center_mass_x = static_cast<int>(returnDouble); // pixel
success = imaqMeasureParticle(image, particleNumber, 0,
IMAQ_MT_CENTER_OF_MASS_Y, &returnDouble);
if (!success) {
return success;
}
par->center_mass_y = (int)returnDouble; // pixel
par->center_mass_y = static_cast<int>(returnDouble); // pixel
/* particle size statistics */
success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_AREA,
@@ -473,28 +474,28 @@ int frcParticleAnalysis(Image* image, int particleNumber,
if (!success) {
return success;
}
par->boundingRect.top = (int)returnDouble;
par->boundingRect.top = static_cast<int>(returnDouble);
success = imaqMeasureParticle(image, particleNumber, 0,
IMAQ_MT_BOUNDING_RECT_LEFT, &returnDouble);
if (!success) {
return success;
}
par->boundingRect.left = (int)returnDouble;
par->boundingRect.left = static_cast<int>(returnDouble);
success = imaqMeasureParticle(image, particleNumber, 0,
IMAQ_MT_BOUNDING_RECT_HEIGHT, &returnDouble);
if (!success) {
return success;
}
par->boundingRect.height = (int)returnDouble;
par->boundingRect.height = static_cast<int>(returnDouble);
success = imaqMeasureParticle(image, particleNumber, 0,
IMAQ_MT_BOUNDING_RECT_WIDTH, &returnDouble);
if (!success) {
return success;
}
par->boundingRect.width = (int)returnDouble;
par->boundingRect.width = static_cast<int>(returnDouble);
/* particle quality statistics */
success = imaqMeasureParticle(image, particleNumber, 0,