adafruit / Adafruit_CircuitPlayground

library for Circuit Playground board
171 stars 77 forks source link

Fix misleading code formatting & bug #63

Open henrygab opened 3 years ago

henrygab commented 3 years ago

GCC properly flags this formatting as misleading. I think it's also a real bug, and should have the two statements wrapped in curly braces.

However, as I am not familiar enough with this code, requesting review / modification / test to ensure it's the proper fix.

...\libraries\Adafruit_CircuitPlayground\utility\IRLibDecodeBase.cpp:
      In member function 'void IRdecodeBase::dumpResults(bool)':
...\libraries\Adafruit_CircuitPlayground\utility\IRLibDecodeBase.cpp:
      Line 59 Char 8
      warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   59 |        if(interval>0)LowSpace=min(LowSpace, interval);  HiSpace=max (HiSpace, interval);
      |        ^~
...\libraries\Adafruit_CircuitPlayground\utility\IRLibDecodeBase.cpp:
      Line 59 Char 57
      note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   59 |        if(interval>0)LowSpace=min(LowSpace, interval);  HiSpace=max (HiSpace, interval);
      |                                                         ^~~~~~~
henrygab commented 3 years ago

Although this shows ladyada as the last editor, it appears to have been a wholesale copy of the library. The same issue exists in the original depot, so I've asked @cyborg5 whether the second statement on that line is intended to be gated by the if or not.

I've manually decoded IR signals before, thanks to AnalysIR and the convenient LearnIR dongle. However, it's not an area of particular strength. Leaving this one as a WIP until the question in the parent depot is resolved.