use replace 0 with NULL for pointers, set some functions static
authorCampbell Barton <ideasman42@gmail.com>
Fri, 16 Sep 2011 08:20:21 +0000 (08:20 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 16 Sep 2011 08:20:21 +0000 (08:20 +0000)
also fixed own errors in recent static check commit.

24 files changed:
build_files/cmake/cmake_static_check_cppcheck.py
build_files/cmake/cmake_static_check_sparse.py
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/node.c
source/blender/blenlib/intern/string_utf8.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/keyframes_edit.c
source/blender/editors/curve/curve_ops.c
source/blender/editors/sound/sound_intern.h
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/gpu/intern/gpu_buffers.c
source/blender/imbuf/intern/indexer.c
source/blender/imbuf/intern/jp2.c
source/blender/modifiers/intern/MOD_weightvg_util.c
source/blender/nodes/composite/node_composite_tree.c
source/blender/nodes/composite/nodes/node_composite_diffMatte.c
source/blender/python/intern/bpy_app_handlers.c
source/blender/python/intern/gpu.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/pipeline.c

index 9b03bbf..4249537 100644 (file)
 
 # <pep8 compliant>
 
+import project_source_info
+import subprocess
+import sys
+import os
+
 CHECKER_IGNORE_PREFIX = [
     "extern",
     "intern/moto",
@@ -31,15 +36,11 @@ CHECKER_IGNORE_PREFIX = [
 CHECKER_BIN = "cppcheck"
 
 CHECKER_ARGS = [
-    "-I/dsk/data/src/blender/blender/extern/glew/include",
+    "-I" + os.join(project_source_info.SORCE_DIR, "blender/extern/glew/include"),
     #  "--check-config", # when includes are missing
     #  "--enable=all",  # if you want sixty hundred pedantic suggestions
     ]
 
-import project_source_info
-import subprocess
-import sys
-
 def main():
     source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX)
 
index 8b30054..7405697 100644 (file)
@@ -23,7 +23,7 @@
 
 # <pep8 compliant>
 
-CHECKER_IGNORE_SUFFIX = [
+CHECKER_IGNORE_PREFIX = [
     "extern",
     "intern/moto",
     ]
index f75773d..73ddcbe 100644 (file)
@@ -117,7 +117,7 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr)
        tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr;
        
        if (adt->action == mlac->act) {
-               if (id->lib==0) {
+               if (id->lib == NULL) {
                        adt->action = mlac->actn;
                        
                        id_us_plus(&mlac->actn->id);
index d40b030..89fd3ff 100644 (file)
@@ -1051,9 +1051,9 @@ void ntreeMakeLocal(bNodeTree *ntree)
        
        if(ntree->id.lib==NULL) return;
        if(ntree->id.us==1) {
-               ntree->id.lib= 0;
+               ntree->id.lib= NULL;
                ntree->id.flag= LIB_LOCAL;
-               new_id(0, (ID *)ntree, 0);
+               new_id(NULL, (ID *)ntree, NULL);
                return;
        }
        
@@ -1069,7 +1069,7 @@ void ntreeMakeLocal(bNodeTree *ntree)
        if(cd.local && cd.lib==0) {
                ntree->id.lib= NULL;
                ntree->id.flag= LIB_LOCAL;
-               new_id(0, (ID *)ntree, 0);
+               new_id(NULL, (ID *)ntree, NULL);
        }
        else if(cd.local && cd.lib) {
                /* this is the mixed case, we copy the tree and assign it to local users */
@@ -1438,7 +1438,7 @@ static void ntree_update_link_pointers(bNodeTree *ntree)
        }
 }
 
-void ntree_validate_links(bNodeTree *ntree)
+static void ntree_validate_links(bNodeTree *ntree)
 {
        bNodeTreeType *ntreetype = ntreeGetType(ntree->type);
        bNodeLink *link;
index 818666e..961a416 100644 (file)
@@ -32,6 +32,8 @@
 
 #include <string.h>
 
+#include "BLI_string.h"
+
 /* from libswish3, originally called u8_isvalid(),
  * modified to return the index of the bad character (byte index not utf).
  * http://svn.swish-e.org/libswish3/trunk/src/libswish3/utf8.c r3044 - campbell */
index bb710a3..bd5935c 100644 (file)
@@ -893,7 +893,7 @@ static size_t skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner
  */
 static short skip_fcurve_with_name (bDopeSheet *ads, FCurve *fcu, ID *owner_id)
 {
-       bAnimListElem ale_dummy = {0};
+       bAnimListElem ale_dummy = {NULL};
        bAnimChannelType *acf;
        
        /* create a dummy wrapper for the F-Curve */
index 2305848..fa619e4 100644 (file)
@@ -204,8 +204,8 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o
        int filter;
        int ret=0;
        
-       bAnimListElem dummychan = {0};
-       Base dummybase = {0};
+       bAnimListElem dummychan = {NULL};
+       Base dummybase = {NULL};
        
        if (ob == NULL)
                return 0;
@@ -249,7 +249,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene
        int filter;
        int ret=0;
        
-       bAnimListElem dummychan = {0};
+       bAnimListElem dummychan = {NULL};
        
        if (sce == NULL)
                return 0;
index adf4f0f..6b85523 100644 (file)
@@ -46,6 +46,7 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+#include "ED_curve.h"
 #include "ED_object.h"
 #include "ED_screen.h"
 #include "ED_transform.h"
index b17ef99..cde0b3c 100644 (file)
@@ -36,7 +36,5 @@
 
 struct wmOperatorType;
 
-void SOUND_OT_open(wmOperatorType *ot);
-
 #endif /* ED_SOUND_INTERN_H */
 
index 19cae6a..60d665d 100644 (file)
@@ -175,7 +175,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *event)
        return WM_operator_filesel(C, op, event);
 }
 
-void SOUND_OT_open(wmOperatorType *ot)
+static void SOUND_OT_open(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Open Sound";
@@ -196,7 +196,7 @@ void SOUND_OT_open(wmOperatorType *ot)
        RNA_def_boolean(ot->srna, "mono", FALSE, "Mono", "Mixdown the sound to mono.");
 }
 
-void SOUND_OT_open_mono(wmOperatorType *ot)
+static void SOUND_OT_open_mono(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Open Sound Mono";
@@ -659,7 +659,7 @@ static int update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op))
        return OPERATOR_FINISHED;
 }
 
-void SOUND_OT_update_animation_flags(wmOperatorType *ot)
+static void SOUND_OT_update_animation_flags(wmOperatorType *ot)
 {
        /*
          This operator is needed to set a correct state of the sound animation
@@ -703,7 +703,7 @@ static int bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
        return OPERATOR_FINISHED;
 }
 
-void SOUND_OT_bake_animation(wmOperatorType *ot)
+static void SOUND_OT_bake_animation(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Update animation cache";
index 9ea1e8e..cd521f7 100644 (file)
@@ -97,7 +97,7 @@ static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v)
        }
 }
 
-void node_socket_button_default(const bContext *C, uiBlock *block,
+static void node_socket_button_default(const bContext *C, uiBlock *block,
                                                                bNodeTree *ntree, bNode *node, bNodeSocket *sock,
                                                                const char *name, int x, int y, int width)
 {
@@ -135,7 +135,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v)
        
        return block;
 }
-void node_socket_button_components(const bContext *C, uiBlock *block,
+static void node_socket_button_components(const bContext *C, uiBlock *block,
                                                                   bNodeTree *ntree, bNode *node, bNodeSocket *sock,
                                                                   const char *name, int x, int y, int width)
 {
@@ -157,7 +157,7 @@ void node_socket_button_components(const bContext *C, uiBlock *block,
        uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, "");
 }
 
-void node_socket_button_color(const bContext *C, uiBlock *block,
+static void node_socket_button_color(const bContext *C, uiBlock *block,
                                                          bNodeTree *ntree, bNode *node, bNodeSocket *sock,
                                                          const char *name, int x, int y, int width)
 {
@@ -179,7 +179,7 @@ void node_socket_button_color(const bContext *C, uiBlock *block,
 
 /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
 
-void node_draw_socket_new(bNodeSocket *sock, float size)
+static void node_draw_socket_new(bNodeSocket *sock, float size)
 {
        float x=sock->locx, y=sock->locy;
        
index ada4bc6..6172273 100644 (file)
@@ -218,7 +218,7 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot)
 
 /* Rename --------------------------------------------------- */
 
-void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports)
+static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports)
 {
        /* can't rename rna datablocks entries */
        if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))
index b2fdd34..efbfbd5 100644 (file)
@@ -342,7 +342,7 @@ static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement
        
        if (id) {
                IdAdtTemplate *iat = (IdAdtTemplate *)tsep->id;
-               PointerRNA ptr = {{0}};
+               PointerRNA ptr = {{NULL}};
                PropertyRNA *prop;
                
                RNA_pointer_create(&iat->id, &RNA_AnimData, iat->adt, &ptr);
index e767365..c3165ad 100644 (file)
@@ -188,7 +188,7 @@ static void proxy_endjob(void *UNUSED(customdata))
 
 }
 
-void seq_proxy_build_job(const bContext *C, Sequence * seq)
+static void seq_proxy_build_job(const bContext *C, Sequence * seq)
 {
        wmJob * steve;
        ProxyJob *pj;
index 4d4561e..ce3a378 100644 (file)
@@ -240,7 +240,7 @@ GPUBuffer *GPU_buffer_alloc(int size)
                   size */
                glGenBuffersARB(1, &buf->id);
                glBindBufferARB(GL_ARRAY_BUFFER_ARB, buf->id);
-               glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, 0, GL_STATIC_DRAW_ARB);
+               glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB);
                glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
        }
        else {
@@ -493,7 +493,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
 
        /* nothing to do for legacy mode */
        if(dm->drawObject->legacy)
-               return 0;
+               return NULL;
 
        cur_index_per_mat = MEM_mallocN(sizeof(int)*object->totmaterial,
                                        "GPU_buffer_setup.cur_index_per_mat");
@@ -513,7 +513,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
                        /* bind the buffer and discard previous data,
                           avoids stalling gpu */
                        glBindBufferARB(target, buffer->id);
-                       glBufferDataARB(target, buffer->size, 0, GL_STATIC_DRAW_ARB);
+                       glBufferDataARB(target, buffer->size, NULL, GL_STATIC_DRAW_ARB);
 
                        /* attempt to map the buffer */
                        if(!(varray = glMapBufferARB(target, GL_WRITE_ONLY_ARB))) {
index 3528318..2e45c0e 100644 (file)
@@ -159,24 +159,24 @@ struct anim_index * IMB_indexer_open(const char * name)
        int i;
 
        if (!fp) {
-               return 0;
+               return NULL;
        }
 
        if (fread(header, 12, 1, fp) != 1) {
                fclose(fp);
-               return 0;
+               return NULL;
        }
 
        header[12] = 0;
 
        if (memcmp(header, magic, 8) != 0) {
                fclose(fp);
-               return 0;
+               return NULL;
        }
 
        if (atoi(header+9) != INDEX_FILE_VERSION) {
                fclose(fp);
-               return 0;
+               return NULL;
        }
 
        idx = MEM_callocN( sizeof(struct anim_index), "anim_index");
@@ -916,7 +916,7 @@ static AviMovie * alloc_proxy_output_avi(
 
        if (AVI_open_compress (filename, avi, 1, format) != AVI_ERROR_NONE) {
                MEM_freeN(avi);
-               return 0;
+               return NULL;
        }
                        
        AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x);
@@ -1000,7 +1000,7 @@ static void index_rebuild_fallback(struct anim * anim,
                                                 s_ibuf->rect, x * y * 4);
 
                                /* note that libavi free's the buffer... */
-                               s_ibuf->rect = 0;
+                               s_ibuf->rect = NULL;
 
                                IMB_freeImBuf(s_ibuf);
                        }
@@ -1056,14 +1056,14 @@ void IMB_free_indices(struct anim * anim)
        for (i = 0; i < IMB_PROXY_MAX_SLOT; i++) {
                if (anim->proxy_anim[i]) {
                        IMB_close_anim(anim->proxy_anim[i]);
-                       anim->proxy_anim[i] = 0;
+                       anim->proxy_anim[i] = NULL;
                }
        }
 
        for (i = 0; i < IMB_TC_MAX_SLOT; i++) {
                if (anim->curr_idx[i]) {
                        IMB_indexer_close(anim->curr_idx[i]);
-                       anim->curr_idx[i] = 0;
+                       anim->curr_idx[i] = NULL;
                }
        }
 
@@ -1116,7 +1116,7 @@ struct anim_index * IMB_anim_open_index(
        }
 
        if (anim->indices_tried & tc) {
-               return 0;
+               return NULL;
        }
 
        get_tc_filename(anim, tc, fname);
index a4eae49..af7f098 100644 (file)
@@ -97,7 +97,7 @@ static void info_callback(const char *msg, void *client_data) {
 
 struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
 {
-       struct ImBuf *ibuf = 0;
+       struct ImBuf *ibuf = NULL;
        int use_float = 0; /* for precision higher then 8 use float */
        
        long signed_offsets[4]= {0, 0, 0, 0};
@@ -117,7 +117,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags)
        opj_dinfo_t* dinfo = NULL;      /* handle to a decompressor */
        opj_cio_t *cio = NULL;
 
-       if (check_jp2(mem) == 0) return(0);
+       if (check_jp2(mem) == 0) return(NULL);
 
        /* configure the event callbacks (not required) */
        memset(&event_mgr, 0, sizeof(opj_event_mgr_t));
index 7cdd7b2..128e888 100644 (file)
@@ -228,7 +228,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne
 }
 
 /* Adds the given vertex to the specified vertex group, with given weight. */
-void defvert_add_to_group(MDeformVert *dv, int defgrp_idx, const float weight) {
+static void defvert_add_to_group(MDeformVert *dv, int defgrp_idx, const float weight) {
        /* TODO, move into deform.c as a generic function. This assumes the vertex
         * groups have already been checked, so this has to remain low level. */
        MDeformWeight *newdw;
@@ -247,7 +247,7 @@ void defvert_add_to_group(MDeformVert *dv, int defgrp_idx, const float weight) {
 /* Removes the given vertex from the vertex group, specified either by its defgrp_idx,
  * or directly by its MDeformWeight pointer, if dw is not NULL.
  * WARNING: This function frees the given MDeformWeight, do not use it afterward! */
-void defvert_remove_from_group(MDeformVert *dv, int defgrp_idx, MDeformWeight *dw) {
+static void defvert_remove_from_group(MDeformVert *dv, int defgrp_idx, MDeformWeight *dw) {
        /* TODO, move this into deform.c as a generic function. */
        MDeformWeight *newdw;
        int i;
index 01e46ed..5c58070 100644 (file)
@@ -337,7 +337,7 @@ static void *exec_composite_node(void *nodeexec_v)
                node->typeinfo->newexecfunc(thd->rd, 0, node, nodeexec->data, nsin, nsout);
        
        node->exec |= NODE_READY;
-       return 0;
+       return NULL;
 }
 
 /* return total of executable nodes, for timecursor */
index 23bcf57..9f4af0e 100644 (file)
@@ -88,9 +88,9 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float *
 
 static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 {
-       CompBuf *outbuf=0;
-       CompBuf *imbuf1=0;
-       CompBuf *imbuf2=0;
+       CompBuf *outbuf= NULL;
+       CompBuf *imbuf1= NULL;
+       CompBuf *imbuf2= NULL;
        NodeChroma *c;
 
        /*is anything connected?*/
index e7e4616..b909a0d 100644 (file)
@@ -63,7 +63,7 @@ static PyStructSequence_Desc app_cb_info_desc= {
 #endif
 */
 
-static PyObject *py_cb_array[BLI_CB_EVT_TOT]= {0};
+static PyObject *py_cb_array[BLI_CB_EVT_TOT]= {NULL};
 
 static PyObject *make_app_cb_info(void)
 {
@@ -102,7 +102,7 @@ PyObject *BPY_app_handlers_struct(void)
 
        /* assign the C callbacks */
        if(ret) {
-               static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT]= {{0}};
+               static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT]= {{NULL}};
                bCallbackFuncStore *funcstore;
                int pos= 0;
 
index 334bb1f..8fa6a7b 100644 (file)
@@ -55,6 +55,8 @@
 
 #include "bpy_rna.h"
 
+#include "gpu.h"
+
 #define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, #name, name)
 
 PyDoc_STRVAR(M_gpu_doc,
index 66a73b4..e2b3b23 100644 (file)
@@ -240,8 +240,8 @@ static void envmap_transmatrix(float mat[][4], int part)
        copy_m4_m4(tmat, mat);
        eul_to_mat4( rotmat,eul);
        mul_serie_m4(mat, tmat, rotmat,
-                                        0,   0,    0,
-                                        0,   0,    0);
+                                        NULL, NULL, NULL,
+                                        NULL, NULL, NULL);
 }
 
 /* ------------------------------------------------------------------------- */
index 49e5e7b..05bcc32 100644 (file)
@@ -1452,10 +1452,12 @@ void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle))
 
 /* object is considered fully prepared on correct time etc */
 /* includes lights */
+#if 0
 void RE_AddObject(Render *UNUSED(re), Object *UNUSED(ob))
 {
        
 }
+#endif
 
 /* *************************************** */