From de01badbc6098fe8a2f68afef5bc984b9ed371a5 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 21 Oct 2016 12:55:34 +0200 Subject: [PATCH] cppcheck: fix possible null deref and unused structs --- src/libffi.c | 12 ++++++------ src/libjit.c | 22 ++++++---------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/libffi.c b/src/libffi.c index 5dce76b..8cf29dd 100644 --- a/src/libffi.c +++ b/src/libffi.c @@ -449,12 +449,12 @@ static zend_function_entry *psi_ffi_compile(struct psi_context *C) if (!impl->decl) { continue; } - - if ((call = psi_ffi_call_alloc(C, impl->decl))) { - if (FFI_OK != psi_ffi_call_init_closure(C, call, impl)) { - psi_ffi_call_free(call); - continue; - } + if (!(call = psi_ffi_call_alloc(C, impl->decl))) { + continue; + } + if (FFI_OK != psi_ffi_call_init_closure(C, call, impl)) { + psi_ffi_call_free(call); + continue; } zf->fname = impl->func->name + (impl->func->name[0] == '\\'); diff --git a/src/libjit.c b/src/libjit.c index f99c039..23d53c1 100644 --- a/src/libjit.c +++ b/src/libjit.c @@ -180,10 +180,6 @@ static inline jit_type_t psi_jit_decl_arg_type(decl_arg *darg) { struct psi_jit_context { jit_context_t jit; jit_type_t signature; - struct { - struct psi_jit_data **list; - size_t count; - } data; }; struct psi_jit_call { @@ -192,12 +188,6 @@ struct psi_jit_call { void *params[1]; /* [type1, type2, NULL, arg1, arg2] ... */ }; -struct psi_jit_data { - struct psi_jit_context *context; - impl *impl; - zend_internal_arg_info *arginfo; -}; - static inline struct psi_jit_call *psi_jit_call_alloc(struct psi_context *C, decl *decl) { size_t i, c = decl->args ? decl->args->count : 0; struct psi_jit_call *call = calloc(1, sizeof(*call) + 2 * c * sizeof(void *)); @@ -388,12 +378,12 @@ static zend_function_entry *psi_jit_compile(struct psi_context *C) if (!impl->decl) { continue; } - - if ((call = psi_jit_call_alloc(C, impl->decl))) { - if (!psi_jit_call_init_closure(C, call, impl)) { - psi_jit_call_free(call); - continue; - } + if (!(call = psi_jit_call_alloc(C, impl->decl))) { + continue; + } + if (!psi_jit_call_init_closure(C, call, impl)) { + psi_jit_call_free(call); + continue; } zf->fname = impl->func->name + (impl->func->name[0] == '\\'); -- 2.30.2