trace save: return the download and file errors

It returned PM3_SUCCESS when the trace download or writing the file
failed, so scripts carried on as if the trace was saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5.5 committed 2026-11-09 14:55:58 +07:00
1 parent b9863f3156
commit bd47a48d50
1 file changed
+7 -4
+7 -4
View File
@@ -1637,12 +1637,15 @@ static int CmdTraceSave(const char *Cmd) {
if ((use_buffer == false) && IfPm3Present()) {
// saving is not supposed to alter the client side trace buffer, so
// download to a buffer of our own and leave gs_trace alone
if (download_trace_ex(&trace, &trace_len) != PM3_SUCCESS) {
return PM3_SUCCESS;
int res = download_trace_ex(&trace, &trace_len);
if (res != PM3_SUCCESS) {
return res;
}
is_owner = true;
}
int res = PM3_SUCCESS;
if (trace_len == 0) {
PrintAndLogEx(WARNING, "trace is empty, nothing to save");
if (use_buffer) {
@@ -1651,13 +1654,13 @@ static int CmdTraceSave(const char *Cmd) {
PrintAndLogEx(HINT, "Hint: Try `" _YELLOW_("trace load") "` to load a trace from file");
}
} else {
saveFile(filename, ".trace", trace, trace_len);
res = saveFile(filename, ".trace", trace, trace_len);
}
if (is_owner) {
free(trace);
}
return PM3_SUCCESS;
return res;
}
int CmdTraceListAlias(const char *Cmd, const char *alias, const char *protocol) {