Skip to content

Commit fc530e2

Browse files
cmagliefacchinm
authored andcommitted
USBDevice: made recv fallthru to a single return
1 parent 3316756 commit fc530e2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

cores/arduino/USB/SAMD21_USBDevice.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ class DoubleBufferedEPOutHandler : public EPHandler {
260260
virtual uint32_t recv(void *_data, uint32_t len)
261261
{
262262
uint8_t *data = reinterpret_cast<uint8_t *>(_data);
263+
uint32_t i = 0;
263264

264265
// R/W: current, first0/1, ready0/1, notify
265266
// R : last0/1, data0/1
@@ -270,8 +271,7 @@ class DoubleBufferedEPOutHandler : public EPHandler {
270271
}
271272
}
272273
// when ready0==true the buffer is not being filled and last0 is constant
273-
uint32_t i;
274-
for (i=0; i<len && first0 < last0; i++) {
274+
for (; i<len && first0 < last0; i++) {
275275
data[i] = data0[first0++];
276276
}
277277
if (first0 == last0) {
@@ -285,16 +285,14 @@ class DoubleBufferedEPOutHandler : public EPHandler {
285285
}
286286
}
287287
}
288-
return i;
289288
} else {
290289
synchronized {
291290
if (!ready1) {
292291
return 0;
293292
}
294293
}
295294
// when ready1==true the buffer is not being filled and last1 is constant
296-
uint32_t i;
297-
for (i=0; i<len && first1 < last1; i++) {
295+
for (; i<len && first1 < last1; i++) {
298296
data[i] = data1[first1++];
299297
}
300298
if (first1 == last1) {
@@ -308,8 +306,8 @@ class DoubleBufferedEPOutHandler : public EPHandler {
308306
}
309307
}
310308
}
311-
return i;
312309
}
310+
return i;
313311
}
314312

315313
virtual void handleEndpoint()

0 commit comments

Comments
 (0)