Fix a few harmless maybe uninitialized warnings with GCC 5.4.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 20 Jul 2017 21:51:15 +0000 (23:51 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 20 Jul 2017 22:54:58 +0000 (00:54 +0200)
GCC seems to detect uninitialized into function calls now, but then isn't
always smart enough to see that it is actually initialized. Disabling this
warning entirely seems a bit too much, so initialize a bit more now.

intern/cycles/blender/blender_mesh.cpp
intern/cycles/blender/blender_util.h
intern/cycles/util/util_task.cpp
source/blender/blenkernel/intern/image_gen.c
source/blender/editors/sculpt_paint/paint_image_proj.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/space_image/image_ops.c
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/imbuf/intern/rectop.c

index 3ebe2d8cf3422839092b4a9936e3cd6cfc7407a5..b4cca5f00f4eb904c93cb58de74f7522e75d289b 100644 (file)
@@ -50,8 +50,7 @@ enum {
  * Two triangles has vertex indices in the original Blender-side face.
  * If face is already a quad tri_b will not be initialized.
  */
-inline void face_split_tri_indices(const int num_verts,
-                                   const int face_flag,
+inline void face_split_tri_indices(const int face_flag,
                                    int tri_a[3],
                                    int tri_b[3])
 {
@@ -59,21 +58,19 @@ inline void face_split_tri_indices(const int num_verts,
                tri_a[0] = 0;
                tri_a[1] = 1;
                tri_a[2] = 3;
-               if(num_verts == 4) {
-                       tri_b[0] = 2;
-                       tri_b[1] = 3;
-                       tri_b[2] = 1;
-               }
+
+               tri_b[0] = 2;
+               tri_b[1] = 3;
+               tri_b[2] = 1;
        }
        else /*if(face_flag & FACE_FLAG_DIVIDE_13)*/ {
                tri_a[0] = 0;
                tri_a[1] = 1;
                tri_a[2] = 2;
-               if(num_verts == 4) {
-                       tri_b[0] = 0;
-                       tri_b[1] = 2;
-                       tri_b[2] = 3;
-               }
+
+               tri_b[0] = 0;
+               tri_b[1] = 2;
+               tri_b[2] = 3;
        }
 }
 
@@ -250,7 +247,7 @@ static void mikk_compute_tangents(BL::Mesh& b_mesh,
 
        for(int i = 0; i < nverts.size(); i++) {
                int tri_a[3], tri_b[3];
-               face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b);
+               face_split_tri_indices(face_flags[i], tri_a, tri_b);
 
                tangent[0] = float4_to_float3(userdata.tangent[i*4 + tri_a[0]]);
                tangent[1] = float4_to_float3(userdata.tangent[i*4 + tri_a[1]]);
@@ -376,7 +373,7 @@ static void attr_create_vertex_color(Scene *scene,
 
                        for(l->data.begin(c); c != l->data.end(); ++c, ++i) {
                                int tri_a[3], tri_b[3];
-                               face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b);
+                               face_split_tri_indices(face_flags[i], tri_a, tri_b);
 
                                uchar4 colors[4];
                                colors[0] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color1())));
@@ -469,7 +466,7 @@ static void attr_create_uv_map(Scene *scene,
 
                                for(l->data.begin(t); t != l->data.end(); ++t, ++i) {
                                        int tri_a[3], tri_b[3];
-                                       face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b);
+                                       face_split_tri_indices(face_flags[i], tri_a, tri_b);
 
                                        float3 uvs[4];
                                        uvs[0] = get_float3(t->uv1());
index ebbf325f95b1a0d50ad9873c067200b0d290f494..363e19f7a20b6585961d537cec4c5f05f2be3398 100644 (file)
@@ -51,8 +51,8 @@ static inline BL::Mesh object_to_mesh(BL::BlendData& data,
                                       bool calc_undeformed,
                                       Mesh::SubdivisionType subdivision_type)
 {
-       bool subsurf_mod_show_render;
-       bool subsurf_mod_show_viewport;
+       bool subsurf_mod_show_render = false;
+       bool subsurf_mod_show_viewport = false;
 
        if(subdivision_type != Mesh::SUBDIVISION_NONE) {
                BL::Modifier subsurf_mod = object.modifiers[object.modifiers.length()-1];
index fb0c34e1dc44683cd2100cadaf023cf99e49a50a..6ed97b0e0a63f27f40ea9c4bf72dcef02ef98744 100644 (file)
@@ -206,9 +206,9 @@ void TaskScheduler::init(int num_threads)
                threads.resize(num_threads);
 
                const int num_groups = system_cpu_group_count();
-               unsigned short num_process_groups;
+               unsigned short num_process_groups = 0;
                vector<unsigned short> process_groups;
-               int current_group_threads;
+               int current_group_threads = 0;
                if(num_groups > 1) {
                        process_groups.resize(num_groups);
                        num_process_groups = system_cpu_process_groups(num_groups, 
index 2c8399adece15c3bb27540143fff6a602fa4457c..1f1f4c9d341921742935a6e7064ca368b2696f1f 100644 (file)
@@ -132,7 +132,7 @@ static void image_buf_fill_checker_slice(unsigned char *rect,
        float hsv[3] = {0.0f, 0.9f, 0.9f};
        float rgb[3];
 
-       float dark_linear_color, bright_linear_color;
+       float dark_linear_color = 0.0f, bright_linear_color = 0.0f;
        if (rect_float != NULL) {
                dark_linear_color = srgb_to_linearrgb(0.25f);
                bright_linear_color = srgb_to_linearrgb(0.58f);
index b43581170d0fc6fd31ddd5dd02d4a8620208d4ce..162658f01bb69a810129a9859a3db4cbdb1517f3 100644 (file)
@@ -4754,6 +4754,9 @@ static void *do_projectpaint_thread(void *ph_v)
                                                        copy_v3_v3(texrgb, texrgba);
                                                        mask *= texrgba[3];
                                                }
+                                               else {
+                                                       zero_v3(texrgb);
+                                               }
 
                                                /* extra mask for normal, layer stencil, .. */
                                                mask *= ((float)projPixel->mask) * (1.0f / 65535.0f);
index 31c471c351767fd09dad4d45b6d890f0e08a5117..10628d8cccbba51e5224e6db6fa2bd91899a115f 100644 (file)
@@ -426,7 +426,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr
        Scene *scene = CTX_data_scene(C);
        Paint *paint = BKE_paint_get_active_from_context(C);
        Palette *palette = BKE_paint_palette(paint);
-       PaletteColor *color;
+       PaletteColor *color = NULL;
        Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
        unsigned int col;
        const unsigned char *cp;
index a0d67626940ae9df3ec6d8878ff6bc581560b85f..3c64d1ebb7154607ef75992f5208dea66c133b9c 100644 (file)
@@ -1169,6 +1169,7 @@ static int image_sequence_get_len(ListBase *frames, int *ofs)
                }
                return frame_curr - (*ofs);
        }
+       *ofs = 0;
        return 0;
 }
 
index ec544e653558012ca21200d2853d9a60daac9a3c..1fa3b943524de63956624c45ab3ea7168c391b7e 100644 (file)
@@ -1104,7 +1104,7 @@ void IMB_exr_write_channels(void *handle)
 
        if (data->channels.first) {
                const size_t num_pixels = ((size_t)data->width) * data->height;
-               half *rect_half = NULL, *current_rect_half;
+               half *rect_half = NULL, *current_rect_half = NULL;
 
                /* We allocate teporary storage for half pixels for all the channels at once. */
                if (data->num_half_channels != 0) {
index 086599a37467f1c7c7bcc1306b22b078f732515e..c4325caac91f0ec780ae3733c386c8ae40275b17 100644 (file)
@@ -301,8 +301,8 @@ void IMB_rectblend(ImBuf *dbuf, ImBuf *obuf, ImBuf *sbuf, unsigned short *dmask,
                    int destx,  int desty, int origx, int origy, int srcx, int srcy, int width, int height,
                    IMB_BlendMode mode, bool accumulate)
 {
-       unsigned int *drect = NULL, *orect, *srect = NULL, *dr, *or, *sr;
-       float *drectf = NULL, *orectf, *srectf = NULL, *drf, *orf, *srf;
+       unsigned int *drect = NULL, *orect = NULL, *srect = NULL, *dr, *or, *sr;
+       float *drectf = NULL, *orectf = NULL, *srectf = NULL, *drf, *orf, *srf;
        unsigned short *cmaskrect = curvemask, *cmr;
        unsigned short *dmaskrect = dmask, *dmr;
        unsigned short *texmaskrect = texmask, *tmr;