Merge lp:~mc-return/compiz/compiz.merge-fix1101405-src-session.cpp-cleanup into lp:compiz/0.9.10

Proposed by MC Return
Status: Merged
Approved by: MC Return
Approved revision: 3754
Merged at revision: 3768
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1101405-src-session.cpp-cleanup
Merge into: lp:compiz/0.9.10
Diff against target: 230 lines (+46/-37)
1 file modified
src/session.cpp (+46/-37)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1101405-src-session.cpp-cleanup
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Sam Spilsbury Approve
MC Return Needs Resubmitting
Review via email: mp+173055@code.launchpad.net

Commit message

src/session.cpp cleanup:

Declaration and assignment of local variables in one line.
(this *should* fix bug #1101405)
Use pre- instead of postfix increments.
Added and removed newlines.
Added missing break (just a style issue).
Fixed indentation.

(LP: #1101405)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote :

Hmm, seems unrelated:

99% tests passed, 2 tests failed out of 1474

Total Test time (real) = 2447.30 sec

The following tests FAILED:
 1269 - DecorPixmapProtocolDeleteEndToEnd.TestFreeNotFoundWindowPixmapImmediately (Failed)
 1455 - CompizXorgSystemStackingTest.TestCreateRelativeToDestroyedWindowFindsAnotherAppropriatePosition (Failed)

Revision history for this message
MC Return (mc-return) :
review: Needs Resubmitting
Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote :

The Jenkins failures seem to be unrelated - Re-approving.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/session.cpp'
2--- src/session.cpp 2013-01-19 11:23:07 +0000
3+++ src/session.cpp 2013-07-04 16:12:36 +0000
4@@ -45,19 +45,19 @@
5
6 #define SM_DEBUG(x)
7
8-static SmcConn smcConnection;
9+static SmcConn smcConnection;
10 static CompWatchFdHandle iceWatchFdHandle;
11-static bool connected = false;
12-static bool iceConnected = false;
13+static bool connected = false;
14+static bool iceConnected = false;
15 static char *smClientId, *smPrevClientId;
16
17 static void iceInit (void);
18
19 static void
20-setStringListProperty (SmcConn connection,
21+setStringListProperty (SmcConn connection,
22 const char *name,
23 const char **values,
24- int nValues)
25+ int nValues)
26 {
27 SmProp prop, *pProp;
28
29@@ -65,10 +65,11 @@
30 prop.type = const_cast<char *> (SmLISTofARRAY8);
31
32 prop.vals = (SmPropValue *) malloc (nValues * sizeof (SmPropValue));
33+
34 if (!prop.vals)
35 return;
36
37- for (int i = 0; i < nValues; i++)
38+ for (int i = 0; i < nValues; ++i)
39 {
40 prop.vals[i].value = (char *) values[i];
41 prop.vals[i].length = strlen (values[i]);
42@@ -86,20 +87,19 @@
43 static void
44 setCloneRestartCommands (SmcConn connection)
45 {
46- const char **args;
47-
48 /* at maximum, we pass our old arguments + our new client id
49 to the SM, so allocate for that case */
50- args = (const char **) malloc ((programArgc + 2) * sizeof (char *));
51+ const char **args = (const char **) malloc ((programArgc + 2) * sizeof (char *));
52+
53 if (!args)
54 return;
55
56 int i, count = 0;
57
58- for (i = 0; i < programArgc; i++)
59+ for (i = 0; i < programArgc; ++i)
60 {
61 if (strcmp (programArgv[i], "--sm-client-id") == 0)
62- i++; /* skip old client id, we'll add the new one later */
63+ ++i; /* skip old client id, we'll add the new one later */
64 else if (strcmp (programArgv[i], "--replace") == 0)
65 continue; /* there's nothing to replace when starting session */
66 else
67@@ -112,9 +112,10 @@
68 position 0 is the executable name */
69 for (i = count - 1; i >= 1; i--)
70 args[i + 2] = args[i];
71+
72 args[1] = "--sm-client-id";
73 args[2] = smClientId;
74- count += 2;
75+ count += 2;
76
77 setStringListProperty (connection, SmRestartCommand, args, count);
78
79@@ -125,14 +126,14 @@
80 setRestartStyle (SmcConn connection,
81 char hint)
82 {
83- SmProp prop, *pProp;
84+ SmProp prop, *pProp;
85 SmPropValue propVal;
86
87- prop.name = const_cast<char *> (SmRestartStyleHint);
88- prop.type = const_cast<char *> (SmCARD8);
89- prop.num_vals = 1;
90- prop.vals = &propVal;
91- propVal.value = &hint;
92+ prop.name = const_cast<char *> (SmRestartStyleHint);
93+ prop.type = const_cast<char *> (SmCARD8);
94+ prop.num_vals = 1;
95+ prop.vals = &propVal;
96+ propVal.value = &hint;
97 propVal.length = 1;
98
99 pProp = &prop;
100@@ -141,9 +142,9 @@
101 }
102
103 static void
104-setProgramInfo (SmcConn connection,
105- pid_t pid,
106- uid_t uid)
107+setProgramInfo (SmcConn connection,
108+ pid_t pid,
109+ uid_t uid)
110 {
111 SmProp progProp, pidProp, userProp;
112 SmPropValue progVal, pidVal, userVal;
113@@ -173,6 +174,7 @@
114 props[count++] = &pidProp;
115
116 pw = getpwuid (uid);
117+
118 if (pw)
119 {
120 userProp.name = const_cast<char *> (SmUserID);
121@@ -189,19 +191,19 @@
122 }
123
124 static void
125-saveYourselfCallback (SmcConn connection,
126+saveYourselfCallback (SmcConn connection,
127 SmPointer client_data,
128- int saveType,
129- Bool shutdown,
130- int interact_Style,
131- Bool fast)
132+ int saveType,
133+ Bool shutdown,
134+ int interact_Style,
135+ Bool fast)
136 {
137 CompOption::Vector args;
138
139- args.push_back (CompOption ("save_type", CompOption::TypeInt));
140- args.push_back (CompOption ("shutdown", CompOption::TypeBool));
141+ args.push_back (CompOption ("save_type", CompOption::TypeInt));
142+ args.push_back (CompOption ("shutdown", CompOption::TypeBool));
143 args.push_back (CompOption ("interact_style", CompOption::TypeInt));
144- args.push_back (CompOption ("fast", CompOption::TypeBool));
145+ args.push_back (CompOption ("fast", CompOption::TypeBool));
146
147 args[0].value ().set (saveType);
148 args[1].value ().set ((bool) shutdown);
149@@ -254,13 +256,13 @@
150 callbacks.save_yourself.callback = saveYourselfCallback;
151 callbacks.save_yourself.client_data = NULL;
152
153- callbacks.die.callback = dieCallback;
154+ callbacks.die.callback = dieCallback;
155 callbacks.die.client_data = NULL;
156
157 callbacks.save_complete.callback = saveCompleteCallback;
158 callbacks.save_complete.client_data = NULL;
159
160- callbacks.shutdown_cancelled.callback = shutdownCancelledCallback;
161+ callbacks.shutdown_cancelled.callback = shutdownCancelledCallback;
162 callbacks.shutdown_cancelled.client_data = NULL;
163
164 smcConnection = SmcOpenConnection (NULL,
165@@ -268,7 +270,7 @@
166 SmProtoMajor,
167 SmProtoMinor,
168 SmcSaveYourselfProcMask |
169- SmcDieProcMask |
170+ SmcDieProcMask |
171 SmcSaveCompleteProcMask |
172 SmcShutdownCancelledProcMask,
173 &callbacks,
174@@ -283,10 +285,11 @@
175 else
176 {
177 connected = true;
178+
179 if (prevClientId)
180 smPrevClientId = strdup (prevClientId);
181+
182 setRestartStyle (smcConnection, SmRestartImmediately);
183-
184 }
185 }
186 }
187@@ -306,6 +309,7 @@
188 free (smClientId);
189 smClientId = NULL;
190 }
191+
192 if (smPrevClientId)
193 {
194 free (smPrevClientId);
195@@ -320,14 +324,21 @@
196 if (!connected)
197 return "";
198
199- switch (type) {
200+ switch (type)
201+ {
202 case CompSession::ClientId:
203 if (smClientId)
204 return smClientId;
205+
206 break;
207+
208 case CompSession::PrevClientId:
209 if (smPrevClientId)
210 return smPrevClientId;
211+
212+ break;
213+
214+ default:
215 break;
216 }
217
218@@ -341,11 +352,9 @@
219 static bool
220 iceProcessMessages (IceConn connection)
221 {
222- IceProcessMessagesStatus status;
223-
224 SM_DEBUG (printf ("ICE connection process messages\n"));
225
226- status = IceProcessMessages (connection, NULL, NULL);
227+ IceProcessMessagesStatus status = IceProcessMessages (connection, NULL, NULL);
228
229 if (status == IceProcessMessagesIOError)
230 {

Subscribers

People subscribed via source and target branches

to all changes: