Update Callback to fix fault in serial interrupts

per @c1728p9

Update the Callback class to handle a NULL thunk by returning 0
rather than trying to call the thunk.  This fixes a crash that occurs
on some targets when the TX uart handler is not attached.

Background:
The K64F HAL uart implementation calls the TX interrupt handler
every time a uart interrupt occurs while the TX register is empty.
It does not check to see if the TX interrupt has been enabled.
This means that the TX interrupt can and typically does get
run on RX events.  This causes a crash with the newer callback
code which did not (prior to this patch) support a NULL thunk.
pull/1793/head
Christopher Haster 2016-05-25 16:16:23 -05:00 committed by Jimmy Brisson
parent a7f4262858
commit fbbda73faa
1 changed files with 18 additions and 0 deletions

View File

@ -106,6 +106,9 @@ public:
/** Call the attached function
*/
R call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0, a1, a2, a3, a4);
}
@ -244,6 +247,9 @@ public:
/** Call the attached function
*/
R call(A0 a0, A1 a1, A2 a2, A3 a3) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0, a1, a2, a3);
}
@ -382,6 +388,9 @@ public:
/** Call the attached function
*/
R call(A0 a0, A1 a1, A2 a2) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0, a1, a2);
}
@ -520,6 +529,9 @@ public:
/** Call the attached function
*/
R call(A0 a0, A1 a1) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0, a1);
}
@ -658,6 +670,9 @@ public:
/** Call the attached function
*/
R call(A0 a0) {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func, a0);
}
@ -796,6 +811,9 @@ public:
/** Call the attached function
*/
R call() {
if (!_thunk) {
return (R)0;
}
return _thunk(_obj, &_func);
}