1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

fsm: Include file and line in fsm_sendFailure for DEBUG_LINK

This commit is contained in:
Saleem Rashid 2017-12-11 18:15:31 +00:00 committed by Pavol Rusnak
parent 8fceb961e4
commit b92a0d24b0
2 changed files with 19 additions and 0 deletions

View File

@ -106,7 +106,11 @@ void fsm_sendSuccess(const char *text)
msg_write(MessageType_MessageType_Success, resp);
}
#if DEBUG_LINK
void fsm_sendFailureDebug(FailureType code, const char *text, const char *source)
#else
void fsm_sendFailure(FailureType code, const char *text)
#endif
{
if (protectAbortedByInitialize) {
fsm_msgInitialize((Initialize *)0);
@ -156,10 +160,18 @@ void fsm_sendFailure(FailureType code, const char *text)
break;
}
}
#if DEBUG_LINK
resp->has_message = true;
strlcpy(resp->message, source, sizeof(resp->message));
if (text) {
strlcat(resp->message, text, sizeof(resp->message));
}
#else
if (text) {
resp->has_message = true;
strlcpy(resp->message, text, sizeof(resp->message));
}
#endif
msg_write(MessageType_MessageType_Failure, resp);
}

View File

@ -25,7 +25,14 @@
// message functions
void fsm_sendSuccess(const char *text);
#if DEBUG_LINK
void fsm_sendFailureDebug(FailureType code, const char *text, const char *source);
#define fsm_sendFailure(code, text) fsm_sendFailureDebug((code), (text), __FILE__ ":" VERSTR(__LINE__) ":")
#else
void fsm_sendFailure(FailureType code, const char *text);
#endif
void fsm_msgInitialize(Initialize *msg);
void fsm_msgGetFeatures(GetFeatures *msg);