From ae9b8fb13e2329ec288711f538f01a09de5f75fa Mon Sep 17 00:00:00 2001 From: Noel Eck Date: Wed, 2 Nov 2016 22:26:41 -0700 Subject: [PATCH] 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 --- src/adxrs610/adxrs610.cxx | 2 +- src/bno055/bno055.cxx | 2 +- src/enc03r/enc03r.cxx | 4 ++-- src/grovevdiv/grovevdiv.cxx | 4 ++-- src/guvas12d/guvas12d.cxx | 2 +- src/mic/mic.cxx | 2 +- src/my9221/grovecircularled.cxx | 4 ++-- src/my9221/groveledbar.cxx | 2 +- src/my9221/my9221.cxx | 6 +++--- src/sm130/sm130.cxx | 6 +++--- src/sx1276/sx1276.cxx | 6 +++--- src/tex00/tex00.cxx | 5 +++-- src/vcap/vcap.cxx | 4 ++-- src/vdiv/vdiv.cxx | 4 ++-- src/xbee/xbee.cxx | 2 +- 15 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/adxrs610/adxrs610.cxx b/src/adxrs610/adxrs610.cxx index 30662bbf..c5d3f175 100644 --- a/src/adxrs610/adxrs610.cxx +++ b/src/adxrs610/adxrs610.cxx @@ -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(calibData.size()) != calibrationDataNumBytes) { throw std::invalid_argument(std::string(__FUNCTION__) + ": calibData string must be exactly " diff --git a/src/enc03r/enc03r.cxx b/src/enc03r/enc03r.cxx index 7dc4f65f..679ca08c 100644 --- a/src/enc03r/enc03r.cxx +++ b/src/enc03r/enc03r.cxx @@ -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(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(LEDS_PER_INSTANCE * m_instances); i++) m_bitStates[i] = (((LEDS_PER_INSTANCE * m_instances) - i) <= level) ? m_highIntensity : m_lowIntensity; } diff --git a/src/my9221/groveledbar.cxx b/src/my9221/groveledbar.cxx index c81d0c4a..4b98af7e 100644 --- a/src/my9221/groveledbar.cxx +++ b/src/my9221/groveledbar.cxx @@ -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(m_instances)) barNumber = m_instances - 1; int start = barNumber * LEDS_PER_INSTANCE; diff --git a/src/my9221/my9221.cxx b/src/my9221/my9221.cxx index 4cb10c6c..c5073cf9 100644 --- a/src/my9221/my9221.cxx +++ b/src/my9221/my9221.cxx @@ -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(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(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(m_instances * LEDS_PER_INSTANCE); i++) { if (i % 12 == 0) { diff --git a/src/sm130/sm130.cxx b/src/sm130/sm130.cxx index 79489c08..34e9fa1a 100644 --- a/src/sm130/sm130.cxx +++ b/src/sm130/sm130.cxx @@ -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((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]) diff --git a/src/sx1276/sx1276.cxx b/src/sx1276/sx1276.cxx index 32119c5a..0c4664a4 100644 --- a/src/sx1276/sx1276.cxx +++ b/src/sx1276/sx1276.cxx @@ -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(timeout)) && m_radioEvent == REVENT_EXEC) usleep(100); if (m_radioEvent == REVENT_EXEC) diff --git a/src/tex00/tex00.cxx b/src/tex00/tex00.cxx index 8335b294..95e31c67 100644 --- a/src/tex00/tex00.cxx +++ b/src/tex00/tex00.cxx @@ -179,7 +179,7 @@ float TEX00::thermistor(float ohms) else { // PTC - for (int i=0; i= m_tempVector.size() || next >= m_tempVector.size()) + found >= static_cast(m_tempVector.size()) || + next >= static_cast(m_tempVector.size())) { m_outOfRange = true; // return last measured temperature diff --git a/src/vcap/vcap.cxx b/src/vcap/vcap.cxx index 8a992cec..955fee6b 100644 --- a/src/vcap/vcap.cxx +++ b/src/vcap/vcap.cxx @@ -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(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(m_format.fmt.pix.height) != m_height) { if (m_debugging) cerr << __FUNCTION__ << ": Warning: Selected height " diff --git a/src/vdiv/vdiv.cxx b/src/vdiv/vdiv.cxx index 829a1ea7..867cf66e 100644 --- a/src/vdiv/vdiv.cxx +++ b/src/vdiv/vdiv.cxx @@ -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