adafruit / Adafruit_BluefruitLE_nRF51

Arduino library for nRF51822-based Adafruit Bluefruit LE modules
197 stars 122 forks source link

READ_BUFSIZE should replace hardcoded magic number #30

Open tedhenry100 opened 7 years ago

tedhenry100 commented 7 years ago

The reason for the following line is presumably to avoid reading off the end of packetbuffer.

if (replyidx >= 20) break;

https://github.com/adafruit/Adafruit_BluefruitLE_nRF51/blob/b80b880a62646223ba28b93301164c2134c9f4fc/examples/cplay_neopixel_picker/packetParser.cpp#L83

In the case that the value of READ_BUFSIZE definition higher in the file is changed to a smaller number, the line would be safer and better if written as

if (replyidx >= READ_BUFSIZE) break;