Wsign-compare: Fixed all sign compare warnings in src

This commit addresses all warnings emitted from -Wunused-function
in the C++ src.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2016-11-02 22:26:41 -07:00
parent 1dd5cbb445
commit ae9b8fb13e
15 changed files with 28 additions and 27 deletions

View File

@ -66,7 +66,7 @@ float ADXRS610::calibrateZeroPoint(unsigned int samples)
// The gyro should be in a stable, non-moving state
float sum = 0;
for (int i=0; i<samples; i++)
for (unsigned int i=0; i<samples; i++)
sum += getDataVolts();
return sum / samples;

View File

@ -481,7 +481,7 @@ string BNO055::readCalibrationData()
void BNO055::writeCalibrationData(string calibData)
{
if (calibData.size() != calibrationDataNumBytes)
if (static_cast<int>(calibData.size()) != calibrationDataNumBytes)
{
throw std::invalid_argument(std::string(__FUNCTION__)
+ ": calibData string must be exactly "

View File

@ -59,10 +59,10 @@ unsigned int ENC03R::value()
void ENC03R::calibrate(unsigned int samples)
{
unsigned int val;
int val;
float total = 0.0;
for (int i=0; i<samples; i++)
for (unsigned int i=0; i<samples; i++)
{
val = mraa_aio_read(m_aio);
if (val == -1) throw std::out_of_range(std::string(__FUNCTION__) +

View File

@ -48,9 +48,9 @@ GroveVDiv::~GroveVDiv()
unsigned int GroveVDiv::value(unsigned int samples)
{
unsigned int sum = 0;
int sum = 0;
for (int i=0; i<samples; i++)
for (unsigned int i=0; i<samples; i++)
{
sum += mraa_aio_read(m_aio);
if (sum == -1) return 0;

View File

@ -51,7 +51,7 @@ float GUVAS12D::value(float aref, unsigned int samples)
int val;
unsigned long sum = 0;
for (int i=0; i<samples; i++)
for (unsigned int i=0; i<samples; i++)
{
val = mraa_aio_read(m_aio);
if (val == -1) return -1;

View File

@ -84,7 +84,7 @@ int
Microphone::findThreshold (thresholdContext* ctx, unsigned int threshold,
uint16_t * buffer, int len) {
long sum = 0;
for (unsigned int i = 0; i < len; i++) {
for (int i = 0; i < len; i++) {
sum += buffer[i];
}

View File

@ -77,12 +77,12 @@ void GroveCircularLED::setLevel(uint8_t level, bool direction)
if (!direction)
{
for (int i=0; i<(LEDS_PER_INSTANCE * m_instances); i++)
for (int i=0; i < static_cast<int>(LEDS_PER_INSTANCE * m_instances); i++)
m_bitStates[i] = (i < level) ? m_highIntensity : m_lowIntensity;
}
else
{
for (int i=0; i<(LEDS_PER_INSTANCE * m_instances); i++)
for (int i=0; i< static_cast<int>(LEDS_PER_INSTANCE * m_instances); i++)
m_bitStates[i] = (((LEDS_PER_INSTANCE * m_instances) - i) <= level)
? m_highIntensity : m_lowIntensity;
}

View File

@ -61,7 +61,7 @@ void GroveLEDBar::setBarLevel(uint8_t level, bool greenToRed, int barNumber)
if (level > 10)
level = 10;
if (barNumber >= m_instances)
if (barNumber >= static_cast<int>(m_instances))
barNumber = m_instances - 1;
int start = barNumber * LEDS_PER_INSTANCE;

View File

@ -121,7 +121,7 @@ void MY9221::setHighIntensityValue(int intensity)
void MY9221::setAll()
{
for (int i=0; i<(m_instances * LEDS_PER_INSTANCE); i++)
for (int i=0; i< static_cast<int>(m_instances * LEDS_PER_INSTANCE); i++)
m_bitStates[i] = m_highIntensity;
if (m_autoRefresh)
@ -130,7 +130,7 @@ void MY9221::setAll()
void MY9221::clearAll()
{
for (int i=0; i<(m_instances * LEDS_PER_INSTANCE); i++)
for (int i=0; i< static_cast<int>(m_instances * LEDS_PER_INSTANCE); i++)
m_bitStates[i] = m_lowIntensity;
if (m_autoRefresh)
@ -139,7 +139,7 @@ void MY9221::clearAll()
void MY9221::refresh()
{
for (int i=0; i<(m_instances * LEDS_PER_INSTANCE); i++)
for (int i=0; i< static_cast<int>(m_instances * LEDS_PER_INSTANCE); i++)
{
if (i % 12 == 0)
{

View File

@ -84,7 +84,7 @@ string SM130::sendCommand(CMD_T cmd, string data)
// now the data if any
if (!data.empty())
{
for (int i=0; i<data.size(); i++)
for (size_t i=0; i<data.size(); i++)
{
command.push_back(data[i]);
cksum += (uint8_t)data[i];
@ -129,7 +129,7 @@ string SM130::sendCommand(CMD_T cmd, string data)
}
// check size - 2 header bytes + len + cksum.
if (resp.size() != ((uint8_t)resp[2] + 2 + 1 + 1))
if (resp.size() != static_cast<size_t>((uint8_t)resp[2] + 2 + 1 + 1))
{
cerr << __FUNCTION__ << ": invalid packet length, expected "
<< int((uint8_t)resp[2] + 2 + 1 + 1)
@ -139,7 +139,7 @@ string SM130::sendCommand(CMD_T cmd, string data)
// verify the cksum
cksum = 0;
for (int i=2; i<(resp.size() - 1); i++)
for (size_t i=2; i<(resp.size() - 1); i++)
cksum += (uint8_t)resp[i];
if (cksum != (uint8_t)resp[resp.size() - 1])

View File

@ -312,7 +312,7 @@ void SX1276::init()
setOpMode(MODE_Sleep);
for (int i = 0; i < sizeof(radioRegsInit) / sizeof(radioRegisters_t); i++ )
for (size_t i = 0; i < sizeof(radioRegsInit) / sizeof(radioRegisters_t); i++ )
{
setModem(radioRegsInit[i].Modem);
writeReg(radioRegsInit[i].Addr, radioRegsInit[i].Value);
@ -515,7 +515,7 @@ uint8_t SX1276::lookupFSKBandWidth(uint32_t bw)
// See Table 40 in the datasheet
for (int i=0; i<(sizeof(FskBandwidths)/sizeof(FskBandwidth_t)) - 1; i++)
for (size_t i=0; i<(sizeof(FskBandwidths)/sizeof(FskBandwidth_t)) - 1; i++)
{
if ( (bw >= FskBandwidths[i].bandwidth) &&
(bw < FskBandwidths[i + 1].bandwidth) )
@ -1263,7 +1263,7 @@ SX1276::RADIO_EVENT_T SX1276::setTx(int timeout)
setOpMode(MODE_TxMode);
initClock();
while ((getMillis() < timeout) && m_radioEvent == REVENT_EXEC)
while ((getMillis() < static_cast<uint32_t>(timeout)) && m_radioEvent == REVENT_EXEC)
usleep(100);
if (m_radioEvent == REVENT_EXEC)

View File

@ -179,7 +179,7 @@ float TEX00::thermistor(float ohms)
else
{
// PTC
for (int i=0; i<m_tempVector.size(); i++)
for (size_t i=0; i<m_tempVector.size(); i++)
if (ohms < m_tempVector[i].ohms)
{
found = i;
@ -189,7 +189,8 @@ float TEX00::thermistor(float ohms)
}
if (found < 0 || next < 0 ||
found >= m_tempVector.size() || next >= m_tempVector.size())
found >= static_cast<int>(m_tempVector.size()) ||
next >= static_cast<int>(m_tempVector.size()))
{
m_outOfRange = true;
// return last measured temperature

View File

@ -183,7 +183,7 @@ bool VCAP::setResolution(int width, int height)
}
// G_FMT will have adjusted these if neccessary, so verify
if (m_format.fmt.pix.width != m_width)
if (static_cast<int>(m_format.fmt.pix.width) != m_width)
{
if (m_debugging)
cerr << __FUNCTION__ << ": Warning: Selected width "
@ -195,7 +195,7 @@ bool VCAP::setResolution(int width, int height)
m_width = m_format.fmt.pix.width;
}
if (m_format.fmt.pix.height != m_height)
if (static_cast<int>(m_format.fmt.pix.height) != m_height)
{
if (m_debugging)
cerr << __FUNCTION__ << ": Warning: Selected height "

View File

@ -48,9 +48,9 @@ VDiv::~VDiv()
unsigned int VDiv::value(unsigned int samples)
{
unsigned int sum = 0;
int sum = 0;
for (int i=0; i<samples; i++)
for (unsigned int i=0; i<samples; i++)
{
sum += mraa_aio_read(m_aio);
if (sum == -1) return 0;

View File

@ -94,7 +94,7 @@ bool XBee::commandMode(std::string cmdChars, int guardTimeMS)
string XBee::stringCR2LF(string str)
{
for (int i=0; i<str.size(); i++)
for (size_t i=0; i<str.size(); i++)
if (str[i] == '\r')
str[i] = '\n';