target: do not print an error on shutdown in target events
authorAntonio Borneo <borneo.antonio@gmail.com>
Tue, 2 Jun 2020 12:43:29 +0000 (14:43 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 27 Jun 2020 14:34:51 +0000 (15:34 +0100)
commit7c88e76a76588fa0e3ab645adfc46e8baff6a3e4
treed59e1ad178deaaeed7906b962b6c56b878bd5f03
parent64733434e23d42bfd75932c1e71c39800a5c01e4
target: do not print an error on shutdown in target events

Before commit b3ce5a0ae545 ("target: use LOG_USER to print errors
in events") an error in an event handler was silently lost, while
now the associated message is printed out.

A "shutdown" command in a target event (e.g. in gdb-detach) causes
the event to end with error code ERROR_COMMAND_CLOSE_CONNECTION,
that triggers the error message:
shutdown command invoked
Error executing event <event-name> on target <target-name>:

The error code returned by the command "shutdown" is required to
stop the execution in a script/proc and avoid executing any
further command in the script/proc.
It is then normal to get an error code from the "shutdown" command
and it should not be printed out.

Intercept the return code of the event in case of "shutdown", then
skip scheduling other target events and return without printing
the incorrect error message.

Change-Id: Ia3085fb46beacb90a5e4bf0abf7c6e28bb9e6a9b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Laurent Lemele <laurent.lemele@st.com>
Reviewed-on: http://openocd.zylin.com/5710
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Tested-by: jenkins
src/target/target.c