Skip to content

Commit 3fefe8e

Browse files
sandeepmistrylmihalkovic
authored andcommitted
Cleanup some Stream compiler warnings from arduino#3337
1 parent 04e6389 commit 3fefe8e

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

hardware/arduino/avr/cores/arduino/Stream.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal)
6161

6262
if( c < 0 ||
6363
c == '-' ||
64-
c >= '0' && c <= '9' ||
65-
detectDecimal && c == '.') return c;
64+
(c >= '0' && c <= '9') ||
65+
(detectDecimal && c == '.')) return c;
6666

6767
switch( lookahead ){
6868
case SKIP_NONE: return -1; // Fail code.
@@ -74,6 +74,8 @@ int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal)
7474
case '\n': break;
7575
default: return -1; // Fail code.
7676
}
77+
case SKIP_ALL:
78+
break;
7779
}
7880
read(); // discard non-numeric
7981
}
@@ -138,7 +140,7 @@ long Stream::parseInt(LookaheadMode lookahead, char ignore)
138140

139141
do{
140142
if(c == ignore)
141-
; // ignore this charactor
143+
; // ignore this character
142144
else if(c == '-')
143145
isNegative = true;
144146
else if(c >= '0' && c <= '9') // is c a digit?
@@ -159,7 +161,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
159161
bool isNegative = false;
160162
bool isFraction = false;
161163
long value = 0;
162-
char c;
164+
int c;
163165
float fraction = 1.0;
164166

165167
c = peekNextDigit(lookahead, true);
@@ -182,7 +184,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
182184
read(); // consume the character we got with peek
183185
c = timedPeek();
184186
}
185-
while( (c >= '0' && c <= '9') || c == '.' && !isFraction || c == ignore );
187+
while( (c >= '0' && c <= '9') || (c == '.' && !isFraction) || c == ignore );
186188

187189
if(isNegative)
188190
value = -value;

hardware/arduino/sam/cores/arduino/Stream.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal )
6161

6262
if( c < 0 ||
6363
c == '-' ||
64-
c >= '0' && c <= '9' ||
65-
detectDecimal && c == '.') return c;
64+
(c >= '0' && c <= '9') ||
65+
(detectDecimal && c == '.')) return c;
6666

6767
switch( lookahead ){
6868
case SKIP_NONE: return -1; // Fail code.
@@ -74,6 +74,8 @@ int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal )
7474
case '\n': break;
7575
default: return -1; // Fail code.
7676
}
77+
case SKIP_ALL:
78+
break;
7779
}
7880
read(); // discard non-numeric
7981
}
@@ -159,7 +161,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
159161
bool isNegative = false;
160162
bool isFraction = false;
161163
long value = 0;
162-
char c;
164+
int c;
163165
float fraction = 1.0;
164166

165167
c = peekNextDigit(lookahead, true);
@@ -182,7 +184,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
182184
read(); // consume the character we got with peek
183185
c = timedPeek();
184186
}
185-
while( (c >= '0' && c <= '9') || c == '.' && !isFraction || c == ignore );
187+
while( (c >= '0' && c <= '9') || (c == '.' && !isFraction) || c == ignore );
186188

187189
if(isNegative)
188190
value = -value;

0 commit comments

Comments
 (0)