Skip to content

Commit 3cae482

Browse files
committed
Even more lint fixes.
1 parent 978fe28 commit 3cae482

21 files changed

+78
-47
lines changed

examples/IRMQTTServer/IRMQTTServer.ino

+6-4
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,8 @@ bool parseStringAndSendAirCon(IRsend *irsend, const decode_type_t irType,
16591659
stateSize = inputLength / 2; // Every two hex chars is a byte.
16601660
// Use at least the minimum size.
16611661
stateSize = std::max(stateSize,
1662-
static_cast<uint16_t>(kFujitsuAcStateLengthShort - 1));
1662+
static_cast<uint16_t>(kFujitsuAcStateLengthShort -
1663+
1));
16631664
// If we think it isn't a "short" message.
16641665
if (stateSize > kFujitsuAcStateLengthShort)
16651666
// Then it has to be at least the smaller version of the "normal" size.
@@ -1703,12 +1704,13 @@ bool parseStringAndSendAirCon(IRsend *irsend, const decode_type_t irType,
17031704
// the correct length/byte size.
17041705
stateSize = inputLength / 2; // Every two hex chars is a byte.
17051706
// Use at least the minimum size.
1706-
stateSize = std::max(stateSize, static_cast<uint16_t>(kSamsungAcStateLength));
1707+
stateSize = std::max(stateSize,
1708+
static_cast<uint16_t>(kSamsungAcStateLength));
17071709
// If we think it isn't a "normal" message.
17081710
if (stateSize > kSamsungAcStateLength)
17091711
// Then it probably the extended size.
1710-
stateSize = std::max(stateSize,
1711-
static_cast<uint16_t>(kSamsungAcExtendedStateLength));
1712+
stateSize = std::max(
1713+
stateSize, static_cast<uint16_t>(kSamsungAcExtendedStateLength));
17121714
// Lastly, it should never exceed the maximum "extended" size.
17131715
stateSize = std::min(stateSize, kSamsungAcExtendedStateLength);
17141716
break;

src/IRac.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,8 @@ static stdAc::state_t handleToggles(const stdAc::state_t desired,
574574

575575
/// Common functions for use with all A/Cs supported by the IRac class.
576576
namespace IRAcUtils {
577-
String resultAcToString(const decode_results * const results);
578-
bool decodeToState(const decode_results *decode, stdAc::state_t *result,
579-
const stdAc::state_t *prev = NULL);
577+
String resultAcToString(const decode_results * const results);
578+
bool decodeToState(const decode_results *decode, stdAc::state_t *result,
579+
const stdAc::state_t *prev = NULL);
580580
} // namespace IRAcUtils
581581
#endif // IRAC_H_

src/IRrecv.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1231,8 +1231,8 @@ uint32_t IRrecv::ticksLow(const uint32_t usecs, const uint8_t tolerance,
12311231
/// @return Nr. of ticks.
12321232
uint32_t IRrecv::ticksHigh(const uint32_t usecs, const uint8_t tolerance,
12331233
const uint16_t delta) {
1234-
return ((uint32_t)(usecs * (1.0 + _validTolerance(tolerance) / 100.0)) + 1 +
1235-
delta);
1234+
return (static_cast<uint32_t>(usecs * (1.0 + _validTolerance(tolerance) /
1235+
100.0)) + 1 + delta);
12361236
}
12371237

12381238
/// Check if we match a pulse(measured) with the desired within
@@ -1283,7 +1283,8 @@ bool IRrecv::matchAtLeast(uint32_t measured, uint32_t desired,
12831283
DPRINT(". Matching: ");
12841284
DPRINT(measured);
12851285
DPRINT(" >= ");
1286-
DPRINT(ticksLow(std::min(desired, static_cast<uint32_t>(MS_TO_USEC(params.timeout))),
1286+
DPRINT(ticksLow(std::min(desired,
1287+
static_cast<uint32_t>(MS_TO_USEC(params.timeout))),
12871288
tolerance, delta));
12881289
DPRINT(" [min(");
12891290
DPRINT(ticksLow(desired, tolerance, delta));
@@ -1305,7 +1306,8 @@ bool IRrecv::matchAtLeast(uint32_t measured, uint32_t desired,
13051306
// in the buffer. If that is the case, then assume infinity and return true.
13061307
if (measured == 0) return true;
13071308
return measured >= ticksLow(std::min(
1308-
desired, static_cast<uint32_t>(MS_TO_USEC(params.timeout))), tolerance, delta);
1309+
desired, static_cast<uint32_t>(MS_TO_USEC(params.timeout))), tolerance,
1310+
delta);
13091311
}
13101312

13111313
/// Check if we match a mark signal(measured) with the desired within

src/IRremoteESP8266.h

+16-4
Original file line numberDiff line numberDiff line change
@@ -1507,12 +1507,24 @@ const uint16_t kYorkStateLength = 17;
15071507

15081508
#ifdef DEBUG
15091509
#ifdef UNIT_TEST
1510-
#define DPRINT(x) do { std::cout << x; } while (0)
1511-
#define DPRINTLN(x) do { std::cout << x << std::endl; } while (0)
1510+
#define DPRINT(x) do { \
1511+
std::cout << x; \
1512+
} \
1513+
while (0)
1514+
#define DPRINTLN(x) do { \
1515+
std::cout << x << std::endl; \
1516+
} \
1517+
while (0)
15121518
#endif // UNIT_TEST
15131519
#ifdef ARDUINO
1514-
#define DPRINT(x) do { Serial.print(x); } while (0)
1515-
#define DPRINTLN(x) do { Serial.println(x); } while (0)
1520+
#define DPRINT(x) do { \
1521+
Serial.print(x); \
1522+
} \
1523+
while (0)
1524+
#define DPRINTLN(x) do { \
1525+
Serial.println(x); \
1526+
} \
1527+
while (0)
15161528
#endif // ARDUINO
15171529
#else // DEBUG
15181530
#define DPRINT(x)

src/IRsend.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ uint32_t IRsend::calcUSecPeriod(uint32_t hz, bool use_offset) {
7474
(1000000UL + hz / 2) / hz; // The equiv of round(1000000/hz).
7575
// Apply the offset and ensure we don't result in a <= 0 value.
7676
if (use_offset)
77-
return std::max((uint32_t)1, period + periodOffset);
77+
return std::max(static_cast<uint32_t>(1), period + periodOffset);
7878
else
79-
return std::max((uint32_t)1, period);
79+
return std::max(static_cast<uint32_t>(1), period);
8080
}
8181

8282
/// Set the output frequency modulation and duty cycle.
@@ -174,14 +174,16 @@ uint16_t IRsend::mark(uint16_t usec) {
174174
ledOn();
175175
// Calculate how long we should pulse on for.
176176
// e.g. Are we to close to the end of our requested mark time (usec)?
177-
_delayMicroseconds(std::min((uint32_t)onTimePeriod, usec - elapsed));
177+
_delayMicroseconds(std::min(static_cast<uint32_t>(onTimePeriod),
178+
usec - elapsed));
178179
ledOff();
179180
counter++;
180181
if (elapsed + onTimePeriod >= usec)
181182
return counter; // LED is now off & we've passed our allotted time.
182183
// Wait for the lesser of the rest of the duty cycle, or the time remaining.
183184
_delayMicroseconds(
184-
std::min(usec - elapsed - onTimePeriod, (uint32_t)offTimePeriod));
185+
std::min(usec - elapsed - onTimePeriod,
186+
static_cast<uint32_t>(offTimePeriod)));
185187
elapsed = usecTimer.elapsed(); // Update & recache the actual elapsed time.
186188
}
187189
return counter;
@@ -214,7 +216,7 @@ int8_t IRsend::calibrate(uint16_t hz) {
214216
uint32_t timeTaken = usecTimer.elapsed(); // Record the time it took.
215217
// While it shouldn't be necessary, assume at least 1 pulse, to avoid a
216218
// divide by 0 situation.
217-
pulses = std::max(pulses, (uint16_t)1U);
219+
pulses = std::max(pulses, static_cast<uint16_t>(1U));
218220
uint32_t calcPeriod = calcUSecPeriod(hz); // e.g. @38kHz it should be 26us.
219221
// Assuming 38kHz for the example calculations:
220222
// In a 65535us pulse, we should have 2520.5769 pulses @ 26us periods.

src/IRutils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ uint8_t lowLevelSanityCheck(void) {
14221422
uint64_t _usused_2:18; // 44-61st bits
14231423
uint64_t highest2bits:2; // 62-63rd bits
14241424
};
1425-
uint64_t all;
1425+
uint64_t all;
14261426
};
14271427

14281428
bitpackdata data;

src/IRutils.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,17 @@ bool getBit(const uint8_t data, const uint8_t position);
122122
#define GETBIT32(a, b) ((a) & (static_cast<uint32_t>(1) << (b)))
123123
#define GETBIT64(a, b) ((a) & (static_cast<uint64_t>(1) << (b)))
124124
#define GETBITS8(data, offset, size) \
125-
(((data) & ((static_cast<uint8_t>(UINT8_MAX) >> (8 - (size))) << (offset))) >> \
126-
(offset))
125+
(((data) & ((static_cast<uint8_t>(UINT8_MAX) >> (8 - (size))) << \
126+
(offset))) >> (offset))
127127
#define GETBITS16(data, offset, size) \
128-
(((data) & ((static_cast<uint16_t>(UINT16_MAX) >> (16 - (size))) << (offset))) >> \
129-
(offset))
128+
(((data) & ((static_cast<uint16_t>(UINT16_MAX) >> (16 - (size))) << \
129+
(offset))) >> (offset))
130130
#define GETBITS32(data, offset, size) \
131-
(((data) & ((static_cast<uint32_t>(UINT32_MAX) >> (32 - (size))) << (offset))) >> \
132-
(offset))
131+
(((data) & ((static_cast<uint32_t>(UINT32_MAX) >> (32 - (size))) << \
132+
(offset))) >> (offset))
133133
#define GETBITS64(data, offset, size) \
134-
(((data) & ((static_cast<uint64_t>(UINT64_MAX) >> (64 - (size))) << (offset))) >> \
135-
(offset))
134+
(((data) & ((static_cast<uint64_t>(UINT64_MAX) >> (64 - (size))) << \
135+
(offset))) >> (offset))
136136
uint64_t setBit(const uint64_t data, const uint8_t position,
137137
const bool on = true, const uint8_t size = 64);
138138
uint8_t setBit(const uint8_t data, const uint8_t position,

src/ir_Argo.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <algorithm>
1313
#include <cmath>
1414
#include <cstring>
15+
#include <set>
16+
#include <utility>
1517
#ifndef UNIT_TEST
1618
#include <Arduino.h>
1719
#endif // UNIT_TEST

src/ir_Daikin.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ void IRsend::sendDaikin(const unsigned char data[], const uint16_t nbytes,
7474
sendGeneric(0, 0, // No header for the header
7575
kDaikinBitMark, kDaikinOneSpace, kDaikinBitMark,
7676
kDaikinZeroSpace, kDaikinBitMark, kDaikinZeroSpace + kDaikinGap,
77-
static_cast<uint64_t>(0b00000), kDaikinHeaderLength, 38, false, 0, 50);
77+
static_cast<uint64_t>(0b00000), kDaikinHeaderLength, 38, false,
78+
0, 50);
7879
// Data #1
7980
if (nbytes < kDaikinStateLength) { // Are we using the legacy size?
8081
// Do this as a constant to save RAM and keep in flash memory

src/ir_GlobalCache.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ void IRsend::sendGC(uint16_t buf[], uint16_t len) {
3737
enableIROut(hz);
3838
uint32_t periodic_time = calcUSecPeriod(hz, false);
3939
uint8_t emits =
40-
std::min(buf[kGlobalCacheRptIndex], static_cast<uint16_t>(kGlobalCacheMaxRepeat));
40+
std::min(buf[kGlobalCacheRptIndex],
41+
static_cast<uint16_t>(kGlobalCacheMaxRepeat));
4142
// Repeat
4243
for (uint8_t repeat = 0; repeat < emits; repeat++) {
4344
// First time through, start at the beginning (kGlobalCacheStartIndex),

src/ir_Kelon.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,9 @@ void IRKelonAc::setTimer(uint16_t mins) {
318318
/// @return The timer set minutes
319319
uint16_t IRKelonAc::getTimer() const {
320320
if (_.TimerHours >= 10)
321-
return (static_cast<uint16_t>((_.TimerHours << 1) | _.TimerHalfHour) - 10) * 60;
322-
return (static_cast<uint16_t>(_.TimerHours) * 60) + (_.TimerHalfHour ? 30 : 0);
321+
return (static_cast<uint16_t>((_.TimerHours << 1) | _.TimerHalfHour) -
322+
10) * 60;
323+
return static_cast<uint16_t>(_.TimerHours) * 60 + (_.TimerHalfHour ? 30 : 0);
323324
}
324325

325326
/// Enable or disable the timer. Note that in order to enable the timer the

src/ir_Mirage.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,9 @@ void IRMirageAc::setClock(const uint32_t nr_of_seconds) {
389389
_.Minutes = _.Seconds = 0; // No clock setting. Clear it just in case.
390390
break;
391391
default:
392+
// Limit to 23:59:59
392393
uint32_t remaining = std::min(
393-
nr_of_seconds, static_cast<uint32_t>(24 * 60 * 60 - 1)); // Limit to 23:59:59
394+
nr_of_seconds, static_cast<uint32_t>(24 * 60 * 60 - 1));
394395
_.Seconds = uint8ToBcd(remaining % 60);
395396
remaining /= 60;
396397
_.Minutes = uint8ToBcd(remaining % 60);
@@ -586,7 +587,7 @@ uint16_t IRMirageAc::getOnTimer(void) const {
586587
/// Set the number of minutes for the On Timer.
587588
/// @param[in] nr_of_mins How long to set the timer for. 0 disables the timer.
588589
void IRMirageAc::setOnTimer(const uint16_t nr_of_mins) {
589-
uint16_t mins = std::min(nr_of_mins, (uint16_t)(24 * 60));
590+
uint16_t mins = std::min(nr_of_mins, static_cast<uint16_t>(24 * 60));
590591
switch (_model) {
591592
case mirage_ac_remote_model_t::KKG29AC1:
592593
_.OnTimerEnable = (mins > 0);

src/ir_Panasonic.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ void IRsend::sendPanasonic64(const uint64_t data, const uint16_t nbits,
8888
/// @note This protocol is a modified version of Kaseikyo.
8989
void IRsend::sendPanasonic(const uint16_t address, const uint32_t data,
9090
const uint16_t nbits, const uint16_t repeat) {
91-
sendPanasonic64((static_cast<uint64_t>(address) << 32) | static_cast<uint64_t>(data),
91+
sendPanasonic64(static_cast<uint64_t>(address) << 32 |
92+
static_cast<uint64_t>(data),
9293
nbits, repeat);
9394
}
9495

@@ -107,9 +108,9 @@ uint64_t IRsend::encodePanasonic(const uint16_t manufacturer,
107108
const uint8_t function) {
108109
uint8_t checksum = device ^ subdevice ^ function;
109110
return ((static_cast<uint64_t>(manufacturer) << 32) |
110-
(static_cast<uint64_t>(device) << 24) |
111+
(static_cast<uint64_t>(device) << 24) |
111112
(static_cast<uint64_t>(subdevice) << 16) |
112-
(static_cast<uint64_t>(function) << 8) | checksum);
113+
(static_cast<uint64_t>(function) << 8) | checksum);
113114
}
114115
#endif // (SEND_PANASONIC || SEND_DENON)
115116

src/ir_Pioneer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void IRsend::sendPioneer(const uint64_t data, const uint16_t nbits,
8080
/// `irsend.sendPioneer(irsend.encodePioneer(0xAA1C, 0xAA1C), 64, 0);`
8181
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1749#issuecomment-1028122645
8282
uint64_t IRsend::encodePioneer(const uint16_t address, const uint16_t command) {
83-
return (static_cast<uint64_t>(encodeNEC(address >> 8, address & 0xFF)) << 32) |
83+
return static_cast<uint64_t>(encodeNEC(address >> 8, address & 0xFF)) << 32 |
8484
encodeNEC(command >> 8, command & 0xFF);
8585
}
8686
#endif // SEND_PIONEER

src/ir_Pronto.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ void IRsend::sendPronto(uint16_t data[], uint16_t len, uint16_t repeat) {
6262

6363
// Pronto frequency is in Hz.
6464
uint16_t hz =
65-
static_cast<uint16_t>(1000000U / (data[kProntoFreqOffset] * kProntoFreqFactor));
65+
static_cast<uint16_t>(1000000U / (data[kProntoFreqOffset] *
66+
kProntoFreqFactor));
6667
enableIROut(hz);
6768

6869
// Grab the length of the two sequences.

src/ir_RCMM.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ bool IRrecv::decodeRCMM(decode_results *results, uint16_t offset,
101101

102102
// Calc the maximum size in bits, the message can be, or that we can accept.
103103
int16_t maxBitSize =
104-
std::min(static_cast<uint16_t>(results->rawlen) - 5, (uint16_t)sizeof(data) * 8);
104+
std::min(static_cast<uint16_t>(results->rawlen) - 5,
105+
static_cast<uint16_t>(sizeof(data)) * 8);
105106
// Compliance
106107
if (strict) {
107108
// Technically the spec says bit sizes should be 12 xor 24. however
108109
// 32 bits has been seen from a device. We are going to assume
109110
// 12 <= bits <= 32 is the 'required' bit length for the spec.
110-
if (maxBitSize < 12 || maxBitSize > 32) return false;
111+
if (maxBitSize < 12 || maxBitSize > 32)
112+
return false;
111113
if (maxBitSize < nbits)
112114
return false; // Short cut, we can never reach the expected nr. of bits.
113115
}

src/ir_Sherwood.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/// @note Sherwood remote codes appear to be NEC codes with a mandatory repeat
2020
/// code. i.e. repeat should be >= kSherwoodMinRepeat (1).
2121
void IRsend::sendSherwood(uint64_t data, uint16_t nbits, uint16_t repeat) {
22-
sendNEC(data, nbits, std::max(static_cast<uint16_t>(kSherwoodMinRepeat), repeat));
22+
sendNEC(data, nbits,
23+
std::max(static_cast<uint16_t>(kSherwoodMinRepeat), repeat));
2324
}
2425
#endif // SEND_SHERWOOD

src/ir_Teco.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ uint16_t IRTecoAc::getTimer(void) const {
231231
/// `0` will clear the timer. Max is 24 hrs.
232232
/// @note Time is stored internally in increments of 30 mins.
233233
void IRTecoAc::setTimer(const uint16_t nr_mins) {
234-
uint16_t mins = std::min(nr_mins, static_cast<uint16_t>(24 * 60)); // Limit to 24 hrs
234+
// Limit to 24 hrs
235+
uint16_t mins = std::min(nr_mins, static_cast<uint16_t>(24 * 60));
235236
uint8_t hours = mins / 60;
236237
_.TimerOn = mins > 0; // Set the timer flag.
237238
_.HalfHour = (mins % 60) >= 30;

test/IRutils_test.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@ TEST(TestUtils, setBit) {
611611
EXPECT_EQ(0b100, irutils::setBit(static_cast<uint64_t>(0b110), 1, false));
612612
EXPECT_EQ(0b111, irutils::setBit(static_cast<uint64_t>(0b101), 1, true));
613613
EXPECT_EQ(0b110, irutils::setBit(static_cast<uint64_t>(0b110), 1, true));
614-
EXPECT_EQ(0b11111111, irutils::setBit(static_cast<uint64_t>(0b01111111), 7, true));
614+
EXPECT_EQ(0b11111111,
615+
irutils::setBit(static_cast<uint64_t>(0b01111111), 7, true));
615616
EXPECT_EQ(0, irutils::setBit(static_cast<uint64_t>(0b10000000), 7, false));
616617
// uint8_t Pointer method.
617618
uint8_t data = 0;

tools/gc_decode.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#include <errno.h>
66
#include <inttypes.h>
77
#include <stdio.h>
8-
#include <cstdio.h>
98
#include <string.h>
9+
#include <cstdio>
1010
#include <iostream>
1111
#include <string>
1212
#include "IRac.h"

tools/mode2_decode.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ space 500000
2020
#include <errno.h>
2121
#include <inttypes.h>
2222
#include <stdio.h>
23-
#include <cstdio.h>
2423
#include <string.h>
24+
#include <cstdio>
2525
#include <iostream>
2626
#include <sstream>
2727
#include <string>

0 commit comments

Comments
 (0)