avoid runtime overflow (1 << 31), for RNA and armature layer UI.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 4 Aug 2013 00:01:41 +0000 (00:01 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 4 Aug 2013 00:01:41 +0000 (00:01 +0000)
source/blender/editors/interface/interface_layout.c
source/blender/makesrna/intern/makesrna.c
source/gameengine/Ketsji/KX_MeshProxy.cpp

index 2e80af1b3ad87e623aae8a45973e8104d4ea66b2..079ba97aa9d74f1d2004e1df02fbd92dd28fa294 100644 (file)
@@ -355,7 +355,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
        PropertyType type;
        PropertySubType subtype;
        uiLayout *sub;
-       int a, b;
+       unsigned int a, b;
 
        /* retrieve type and subtype */
        type = RNA_property_type(prop);
@@ -373,8 +373,8 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
                /* special check for layer layout */
                int butw, buth, unit;
                int cols = (len >= 20) ? 2 : 1;
-               int colbuts = len / (2 * cols);
-               int layer_used = 0;
+               const unsigned int colbuts = len / (2 * cols);
+               unsigned int layer_used = 0;
 
                uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE));
 
index f382caaccba0b883fde3552b10f46dccc48e79b8..5237c97ef718bd0725555053f33dfe9d01b5cd48 100644 (file)
@@ -646,13 +646,14 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                        if (prop->flag & PROP_DYNAMIC) {
                                                char *lenfunc = rna_alloc_function_name(srna->identifier, rna_safe_id(prop->identifier),
                                                                                        "get_length");
-                                               fprintf(f, "    int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
-                                               fprintf(f, "    int len = %s(ptr, arraylen);\n\n", lenfunc);
+                                               fprintf(f, "    unsigned int arraylen[RNA_MAX_ARRAY_DIMENSION];\n");
+                                               fprintf(f, "    unsigned int i;\n");
+                                               fprintf(f, "    unsigned int len = %s(ptr, arraylen);\n\n", lenfunc);
                                                fprintf(f, "    for (i = 0; i < len; i++) {\n");
                                                MEM_freeN(lenfunc);
                                        }
                                        else {
-                                               fprintf(f, "    int i;\n\n");
+                                               fprintf(f, "    unsigned int i;\n\n");
                                                fprintf(f, "    for (i = 0; i < %u; i++) {\n", prop->totarraylength);
                                        }
 
index 8e803c4635816f1bbfcaaf8b0f8ebae6e91ee3e9..f7cd13acf27f4a9867076d14be621b7a17151641 100644 (file)
@@ -387,16 +387,13 @@ PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_
        
        
        for (i=0; i<tot; mit++, i++) {
-               RAS_IPolyMaterial *polymat = mit->m_bucket->GetPolyMaterial();   
-               
-               /* Why do we need to check for RAS_BLENDERMAT if both are cast to a (PyObject *)? - Campbell */
-               if (polymat->GetFlag() & RAS_BLENDERMAT)         
-               {        
-                       KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial*>(polymat);     
+               RAS_IPolyMaterial *polymat = mit->m_bucket->GetPolyMaterial();
+               if (polymat->GetFlag() & RAS_BLENDERMAT) {
+                       KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial *>(polymat);
                        PyList_SET_ITEM(materials, i, mat->GetProxy());
                }
                else {
-                       KX_PolygonMaterial *mat = static_cast<KX_PolygonMaterial*>(polymat);
+                       KX_PolygonMaterial *mat = static_cast<KX_PolygonMaterial *>(polymat);
                        PyList_SET_ITEM(materials, i, mat->GetProxy());
                }
        }