We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1e50936 commit 06b53c7Copy full SHA for 06b53c7
src/lmic/lmic.c
@@ -721,11 +721,17 @@ static CONST_TABLE(u1_t, macCmdSize)[] = {
721
};
722
723
static u1_t getMacCmdSize(u1_t macCmd) {
724
- if (macCmd < 2)
725
- return 0;
726
- if (((size_t)(macCmd - 2)) >= LENOF_TABLE(macCmdSize))
727
728
- return TABLE_GET_U1(macCmdSize, macCmd - 2);
+ if (macCmd >= 2) {
+ const unsigned macCmdMinus2 = macCmd - 2u;
+ if (macCmdMinus2 < LENOF_TABLE(macCmdSize)) {
+ // macCmd in table, fetch it's size.
+ return TABLE_GET_U1(macCmdSize, macCmdMinus2);
729
+ }
730
731
+ // macCmd too small or too large: return zero. Zero is
732
+ // never a legal command size, so it signals an error
733
+ // to the caller.
734
+ return 0;
735
}
736
737
static bit_t
0 commit comments