From: Michael Wallner Date: Fri, 21 Oct 2016 10:55:34 +0000 (+0200) Subject: cppcheck: fix possible null deref and unused structs X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=de01badbc6098fe8a2f68afef5bc984b9ed371a5;p=m6w6%2Fext-psi cppcheck: fix possible null deref and unused structs --- 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] == '\\');