Skip to content

Commit 3b6884f

Browse files
committed
get rid of some long-standing warnings
1 parent 8b1cd75 commit 3b6884f

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

Ports.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ void HeadingBoard::pressure(int& temp, int& pres) const {
739739
int dUT = (D2 - C5) - (corr * (long) corr * (D2 >= C5 ? A : B) >> C);
740740
// Serial.print("dUT = ");
741741
// Serial.println(dUT);
742-
temp = 250 + (dUT * C6 >> 16) - (dUT >> D);
742+
temp = 250 + ((long) dUT * C6 >> 16) - (dUT >> D);
743743

744744
word D1 = adcValue(1);
745745
// Serial.print("D1 = ");
@@ -773,7 +773,7 @@ void HeadingBoard::heading(int& xaxis, int& yaxis) {
773773
compass.send();
774774
compass.write(0x00);
775775
compass.receive();
776-
byte tmp, reg = compass.read(0);
776+
byte tmp = compass.read(0);
777777
tmp = compass.read(0);
778778
xaxis = ((tmp << 8) | compass.read(0)) - 2048;
779779
tmp = compass.read(0);
@@ -797,7 +797,7 @@ float CompassBoard::heading () {
797797
write(0x00); // Mode: Continuous-Measurement Mode
798798
receive();
799799
int x = read2(0);
800-
int z = read2(0);
800+
/* int z = */ read2(0);
801801
int y = read2(1);
802802
stop();
803803

@@ -829,7 +829,7 @@ void InfraredPlug::poll() {
829829
memset(buf, 0, sizeof buf);
830830
}
831831
// act only if the bit changed, using the low bit of the nibble fill count
832-
if (bit != (fill & 1) && fill < 2 * sizeof buf) {
832+
if (bit != (fill & 1) && fill < 2 * (int) sizeof buf) {
833833
uint32_t curr = micros(), diff = (curr - prev + 2) >> 2;
834834
if (diff > 65000)
835835
diff = 65000; // * 4 us, i.e. 260 ms
@@ -871,7 +871,7 @@ uint8_t InfraredPlug::decoder(uint8_t nibbles) {
871871
return UNKNOWN;
872872
// valid packet, convert in-place
873873
for (byte i = 0; i < 4; ++i) {
874-
byte v;
874+
byte v = 0;
875875
for (byte j = 0; j < 8; ++j)
876876
v = (v << 1) | (buf[1+j+8*i] >> 5);
877877
buf[i] = v;
@@ -1054,7 +1054,7 @@ void Sleepy::powerDown () {
10541054
// sleep_bod_disable(); // can't use this - not in my avr-libc version!
10551055
#ifdef BODSE
10561056
MCUCR = MCUCR | bit(BODSE) | bit(BODS); // timed sequence
1057-
MCUCR = MCUCR & ~ bit(BODSE) | bit(BODS);
1057+
MCUCR = (MCUCR & ~ bit(BODSE)) | bit(BODS);
10581058
#endif
10591059
}
10601060
sleep_cpu();
@@ -1101,13 +1101,13 @@ void Sleepy::watchdogEvent() {
11011101
++watchdogCounter;
11021102
}
11031103

1104-
Scheduler::Scheduler (byte size) : maxTasks (size), remaining (~0) {
1104+
Scheduler::Scheduler (byte size) : remaining (~0), maxTasks (size) {
11051105
byte bytes = size * sizeof *tasks;
11061106
tasks = (word*) malloc(bytes);
11071107
memset(tasks, 0xFF, bytes);
11081108
}
11091109

1110-
Scheduler::Scheduler (word* buf, byte size) : tasks (buf), maxTasks (size), remaining(~0) {
1110+
Scheduler::Scheduler (word* buf, byte size) : tasks (buf), remaining(~0), maxTasks (size) {
11111111
byte bytes = size * sizeof *tasks;
11121112
memset(tasks, 0xFF, bytes);
11131113
}
@@ -1125,23 +1125,23 @@ char Scheduler::poll() {
11251125
if (tasks[i] < lowest)
11261126
lowest = tasks[i];
11271127
}
1128-
if (lowest != ~0) {
1128+
if (lowest != ~0U) {
11291129
for (byte i = 0; i < maxTasks; ++i) {
1130-
if(tasks[i] != ~0) {
1130+
if(tasks[i] != ~0U) {
11311131
tasks[i] -= lowest;
11321132
}
11331133
}
11341134
}
11351135
remaining = lowest;
1136-
} else if (remaining == ~0) //remaining == ~0 means nothing running
1136+
} else if (remaining == ~0U) //remaining == ~0 means nothing running
11371137
return -2;
11381138
else if (ms100.poll(100))
11391139
--remaining;
11401140
return -1;
11411141
}
11421142

11431143
char Scheduler::pollWaiting() {
1144-
if(remaining == ~0) // Nothing running!
1144+
if(remaining == ~0U) // Nothing running!
11451145
return -2;
11461146
// first wait until the remaining time we need to wait is less than 0.1s
11471147
while (remaining > 0) {
@@ -1162,7 +1162,7 @@ void Scheduler::timer(byte task, word tenths) {
11621162
if (tenths < remaining) {
11631163
word diff = remaining - tenths;
11641164
for (byte i = 0; i < maxTasks; ++i)
1165-
if (tasks[i] != ~0)
1165+
if (tasks[i] != ~0U)
11661166
tasks[i] += diff;
11671167
remaining = tenths;
11681168
}
@@ -1212,9 +1212,9 @@ void InputParser::poll() {
12121212
buffer[fill++] = ch;
12131213
return;
12141214
}
1215-
if (hexmode && ('0' <= ch && ch <= '9' ||
1216-
'A' <= ch && ch <= 'F' ||
1217-
'a' <= ch && ch <= 'f')) {
1215+
if (hexmode && (('0' <= ch && ch <= '9') ||
1216+
('A' <= ch && ch <= 'F') ||
1217+
('a' <= ch && ch <= 'f'))) {
12181218
if (!hasvalue)
12191219
value = 0;
12201220
if (ch > '9')

Ports.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ class DeviceI2C {
285285
uint8_t read(uint8_t last) const
286286
{ return port.read(last); }
287287

288-
uint8_t setAddress(uint8_t me)
288+
void setAddress(uint8_t me)
289289
{ addr = me << 1; }
290290
};
291291

@@ -371,7 +371,7 @@ class Scheduler {
371371
void cancel(byte task);
372372

373373
/// return true if a task timer is not running
374-
byte idle(byte task) { return tasks[task] == ~0; }
374+
byte idle(byte task) { return tasks[task] == ~0U; }
375375
};
376376

377377
/// Interface for the Blink Plug - see http://jeelabs.org/bp
@@ -648,8 +648,8 @@ class InputParser {
648648
} Commands;
649649

650650
/// Set up with a buffer of specified size
651-
InputParser (byte size, Commands PROGMEM*, Stream& =Serial);
652-
InputParser (byte* buf, byte size, Commands PROGMEM*, Stream& =Serial);
651+
InputParser (byte size, Commands*, Stream& =Serial);
652+
InputParser (byte* buf, byte size, Commands*, Stream& =Serial);
653653

654654
/// Number of data bytes
655655
byte count() { return fill; }

PortsSHT11.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ uint8_t SHT11::measure(uint8_t type, void (*delayFun)()) {
184184
return 1;
185185
}
186186

187-
#ifndef __AVR_ATtiny84__ || __AVR_ATtiny44__
187+
#if !defined(__AVR_ATtiny84__) && !defined(__AVR_ATtiny44__)
188188
/** Calculate the current relative humidity and temperature.
189189
* @param rh_true Variable to store the true relative humidity into.
190190
* @param t_C Variable to store the temperature in degree celcius into.

PortsSHT11.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SHT11 : public Port {
3535

3636
uint8_t measure(uint8_t type, void (*delayFun)() =0);
3737

38-
#ifndef __AVR_ATtiny84__ || __AVR_ATtiny44__
38+
#if !defined(__AVR_ATtiny84__) && !defined(__AVR_ATtiny44__)
3939
void calculate(float& rh_true, float& t_C) const;
4040

4141
static float dewpoint(float h, float t);

0 commit comments

Comments
 (0)