forked from auracaster/openocd
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
This commit is contained in:
@@ -346,8 +346,7 @@ void pracc_add_li32(struct pracc_queue_info *ctx, uint32_t reg_num, uint32_t dat
|
||||
|
||||
inline void pracc_queue_free(struct pracc_queue_info *ctx)
|
||||
{
|
||||
if (ctx->pracc_list != NULL)
|
||||
free(ctx->pracc_list);
|
||||
free(ctx->pracc_list);
|
||||
}
|
||||
|
||||
int mips32_pracc_queue_exec(struct mips_ejtag *ejtag_info, struct pracc_queue_info *ctx,
|
||||
@@ -550,8 +549,7 @@ int mips32_pracc_read_mem(struct mips_ejtag *ejtag_info, uint32_t addr, int size
|
||||
}
|
||||
exit:
|
||||
pracc_queue_free(&ctx);
|
||||
if (data != NULL)
|
||||
free(data);
|
||||
free(data);
|
||||
return ctx.retval;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user