Merge lp:~mc-return/compiz/compiz.merge-fix1033877-fix-uninitialized-class-member-variables-in-constructors into lp:compiz/0.9.9

Proposed by MC Return
Status: Merged
Approved by: Stephen M. Webb
Approved revision: 3456
Merged at revision: 3447
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1033877-fix-uninitialized-class-member-variables-in-constructors
Merge into: lp:compiz/0.9.9
Diff against target: 132 lines (+34/-4)
8 files modified
plugins/animation/src/glide.cpp (+2/-1)
plugins/animation/src/magiclamp.cpp (+3/-1)
plugins/composite/src/screen.cpp (+14/-0)
plugins/decor/src/decor.cpp (+1/-0)
plugins/ezoom/src/ezoom.cpp (+7/-1)
plugins/opengl/src/screen.cpp (+1/-0)
plugins/opengl/src/vertexbuffer.cpp (+2/-1)
plugins/staticswitcher/src/staticswitcher.cpp (+4/-0)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1033877-fix-uninitialized-class-member-variables-in-constructors
Reviewer Review Type Date Requested Status
Stephen M. Webb Approve
Sam Spilsbury Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+132813@code.launchpad.net

Commit message

Initialized all class member variables in their respective constructors.
Used false for bools, 0.0f for floats, 0 for ints and 0 for object pointers like *autoProgram and *screen.

Description of the change

Initialized all class member variables in their respective constructors.
Used false for bools, 0.0f for floats, 0 for ints and 0 for object pointers like *autoProgram and *screen.

Should I have used NULL to initialize the individual object pointers ?

Note: I did not fix the same issue for currently disabled plug-ins like trip or non-working plug-ins like firepaint or showmouse. So these tasks still remain open.

To post a comment you must log in.
3455. By MC Return

Also initialize the member variables int previewWidth, previewHeight, previewBorder and xCount in the StaticSwitchScreen::StaticSwitchScreen (CompScreen *screen) constructor

3456. By MC Return

Also initialize the member variable int refCount in the Decoration::Decoration (...) constructor

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

This is good, although I remember someone once told me that they get zero-initialized automatically. I could be wrong though.

review: Approve
Revision history for this message
MC Return (mc-return) wrote :

Thanks a lot for the review and approval. I was not sure if 0 is the best initialization value everywhere, but I am currently running all those changes here and all seems good. :)

Regarding the auto zero-initialization: I do not know. Maybe it also depends on the compiler. Maybe it is just a question of style. But I thought it would not hurt to eliminate the complaints cppcheck has. ;)
Also almost all of such cases do get initialized manually already, so I thought it would be best to do it for all of them.
(some still remain - see description note above)

Revision history for this message
Stephen M. Webb (bregma) wrote :

For the record: member variables do not get initialized automatically, they remain uninitialized (undefined values). Zero for pointer initialization instead of NULL is OK since NULL is required to be a #define for 0 in C++ but the value nullptr is better if the code is compiled using the current standard.

This change is good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/animation/src/glide.cpp'
2--- plugins/animation/src/glide.cpp 2009-07-15 16:05:10 +0000
3+++ plugins/animation/src/glide.cpp 2012-11-04 18:08:20 +0000
4@@ -45,7 +45,8 @@
5 const CompRect &icon) :
6 Animation::Animation (w, curWindowEvent, duration, info, icon),
7 TransformAnim::TransformAnim (w, curWindowEvent, duration, info, icon),
8- ZoomAnim::ZoomAnim (w, curWindowEvent, duration, info, icon)
9+ ZoomAnim::ZoomAnim (w, curWindowEvent, duration, info, icon),
10+ glideModRotAngle (0.0f)
11 {
12 }
13
14
15=== modified file 'plugins/animation/src/magiclamp.cpp'
16--- plugins/animation/src/magiclamp.cpp 2012-05-18 06:52:20 +0000
17+++ plugins/animation/src/magiclamp.cpp 2012-11-04 18:08:20 +0000
18@@ -58,7 +58,9 @@
19 const AnimEffect info,
20 const CompRect &icon) :
21 Animation::Animation (w, curWindowEvent, duration, info, icon),
22- GridAnim::GridAnim (w, curWindowEvent, duration, info, icon)
23+ GridAnim::GridAnim (w, curWindowEvent, duration, info, icon),
24+ mTopLeftCornerObject (0),
25+ mBottomLeftCornerObject (0)
26 {
27 CompRect outRect (mAWindow->savedRectsValid () ?
28 mAWindow->savedOutRect () :
29
30=== modified file 'plugins/composite/src/screen.cpp'
31--- plugins/composite/src/screen.cpp 2012-10-16 05:11:10 +0000
32+++ plugins/composite/src/screen.cpp 2012-11-04 18:08:20 +0000
33@@ -279,6 +279,20 @@
34
35 PrivateCompositeScreen::PrivateCompositeScreen (CompositeScreen *cs) :
36 cScreen (cs),
37+ compositeEvent (0),
38+ compositeError (0),
39+ compositeOpcode (0),
40+ damageEvent (0),
41+ damageError (0),
42+ fixesEvent (0),
43+ fixesError (0),
44+ fixesVersion (0),
45+ shapeExtension (false),
46+ shapeEvent (0),
47+ shapeError (0),
48+ randrExtension (false),
49+ randrEvent (0),
50+ randrError (0),
51 damageMask (COMPOSITE_SCREEN_DAMAGE_ALL_MASK),
52 overlay (None),
53 output (None),
54
55=== modified file 'plugins/decor/src/decor.cpp'
56--- plugins/decor/src/decor.cpp 2012-09-17 15:25:00 +0000
57+++ plugins/decor/src/decor.cpp 2012-11-04 18:08:20 +0000
58@@ -597,6 +597,7 @@
59 unsigned int nQuad,
60 Window owner,
61 DecorPixmapRequestorInterface *requestor) :
62+ refCount (0),
63 texture (DecorScreen::get (screen)->getTexture (pixmap)),
64 border (border.left, border.right, border.top, border.bottom),
65 input (input.left, input.right, input.top, input.bottom),
66
67=== modified file 'plugins/ezoom/src/ezoom.cpp'
68--- plugins/ezoom/src/ezoom.cpp 2012-10-15 12:51:26 +0000
69+++ plugins/ezoom/src/ezoom.cpp 2012-11-04 18:08:20 +0000
70@@ -211,6 +211,7 @@
71 }
72
73 EZoomScreen::ZoomArea::ZoomArea () :
74+ output (0),
75 viewport (~0),
76 currentZoom (1.0f),
77 newZoom (1.0f),
78@@ -1874,7 +1875,12 @@
79 /* TODO: Use this ctor carefully */
80
81 EZoomScreen::CursorTexture::CursorTexture () :
82- isSet (false)
83+ isSet (false),
84+ screen (0),
85+ width (0),
86+ height (0),
87+ hotX (0),
88+ hotY (0)
89 {
90 }
91
92
93=== modified file 'plugins/opengl/src/screen.cpp'
94--- plugins/opengl/src/screen.cpp 2012-10-16 04:49:19 +0000
95+++ plugins/opengl/src/screen.cpp 2012-11-04 18:08:20 +0000
96@@ -1147,6 +1147,7 @@
97 #endif
98 scratchFbo (NULL),
99 outputRegion (),
100+ refreshSubBuffer (false),
101 lastMask (0),
102 bindPixmap (),
103 hasCompositing (false),
104
105=== modified file 'plugins/opengl/src/vertexbuffer.cpp'
106--- plugins/opengl/src/vertexbuffer.cpp 2012-09-05 23:54:21 +0000
107+++ plugins/opengl/src/vertexbuffer.cpp 2012-11-04 18:08:20 +0000
108@@ -387,7 +387,8 @@
109 nTextures (0),
110 vertexOffset (0),
111 maxVertices (-1),
112- program (NULL)
113+ program (NULL),
114+ autoProgram (0)
115 {
116 if (!GL::genBuffers)
117 return;
118
119=== modified file 'plugins/staticswitcher/src/staticswitcher.cpp'
120--- plugins/staticswitcher/src/staticswitcher.cpp 2012-09-07 23:56:21 +0000
121+++ plugins/staticswitcher/src/staticswitcher.cpp 2012-11-04 18:08:20 +0000
122@@ -1345,6 +1345,10 @@
123 BaseSwitchScreen (screen),
124 PluginClassHandler<StaticSwitchScreen,CompScreen> (screen),
125 clientLeader (None),
126+ previewWidth (0),
127+ previewHeight (0),
128+ previewBorder (0),
129+ xCount (0),
130 switching (false),
131 mVelocity (0.0),
132 pos (0),

Subscribers

People subscribed via source and target branches