cppcheck: fix possible null deref and unused structs
authorMichael Wallner <mike@php.net>
Fri, 21 Oct 2016 10:55:34 +0000 (12:55 +0200)
committerMichael Wallner <mike@php.net>
Fri, 21 Oct 2016 10:55:34 +0000 (12:55 +0200)
src/libffi.c
src/libjit.c

index 5dce76bb4e921932a50c539691da7ac810c599f0..8cf29ddbd7dc445c29b302e6fbc1c48cab1d47b2 100644 (file)
@@ -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] == '\\');
index f99c0390f5932b54f69808aa4f21c5e4ddbe065d..23d53c16a4efe9ceb70702c1bf9634e4b36e5b1c 100644 (file)
@@ -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] == '\\');