aboutsummaryrefslogtreecommitdiff
path: root/src/target/openrisc/jsp_server.c
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2020-08-17 09:58:58 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2020-09-05 20:47:11 +0100
commit3934483429b77525f25922787933fb7ee3e73a0f (patch)
tree5cf5d1d4ebe72c1cd437d6b0f6d359465604928d /src/target/openrisc/jsp_server.c
parent0dad8cbfe9e1d43cdcabbc8eb4e2809b7b21381d (diff)
downloadriscv-openocd-3934483429b77525f25922787933fb7ee3e73a0f.zip
riscv-openocd-3934483429b77525f25922787933fb7ee3e73a0f.tar.gz
riscv-openocd-3934483429b77525f25922787933fb7ee3e73a0f.tar.bz2
target: avoid checking for non NULL pointer to free it
The function free() can be called with a NULL pointer as argument, no need to check the argument before. If the pointer is NULL, no operation is performed by free(). Remove the occurrences of pattern: if (ptr) free(ptr); In target/openrisc/jsp_server.c, an error is logged if the ptr was already NULL. This cannot happen since the pointer was already referenced few lines before and openocd would have been already SIGSEGV in that case, so remove the log. Change-Id: I290a32e6d4deab167676af4ddc83523c830ae49e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5809 Tested-by: jenkins
Diffstat (limited to 'src/target/openrisc/jsp_server.c')
-rw-r--r--src/target/openrisc/jsp_server.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/target/openrisc/jsp_server.c b/src/target/openrisc/jsp_server.c
index f28815d..1d05944 100644
--- a/src/target/openrisc/jsp_server.c
+++ b/src/target/openrisc/jsp_server.c
@@ -190,12 +190,8 @@ static int jsp_connection_closed(struct connection *connection)
if (ERROR_OK != retval)
return retval;
- if (connection->priv) {
- free(connection->priv);
- connection->priv = NULL;
- } else
- LOG_ERROR("BUG: connection->priv == NULL");
-
+ free(connection->priv);
+ connection->priv = NULL;
return ERROR_OK;
}