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
=== modified file 'src/session.cpp'
--- src/session.cpp 2013-01-19 11:23:07 +0000
+++ src/session.cpp 2013-07-04 16:12:36 +0000
@@ -45,19 +45,19 @@
4545
46#define SM_DEBUG(x)46#define SM_DEBUG(x)
4747
48static SmcConn smcConnection;48static SmcConn smcConnection;
49static CompWatchFdHandle iceWatchFdHandle;49static CompWatchFdHandle iceWatchFdHandle;
50static bool connected = false;50static bool connected = false;
51static bool iceConnected = false;51static bool iceConnected = false;
52static char *smClientId, *smPrevClientId;52static char *smClientId, *smPrevClientId;
5353
54static void iceInit (void);54static void iceInit (void);
5555
56static void56static void
57setStringListProperty (SmcConn connection,57setStringListProperty (SmcConn connection,
58 const char *name,58 const char *name,
59 const char **values,59 const char **values,
60 int nValues)60 int nValues)
61{61{
62 SmProp prop, *pProp;62 SmProp prop, *pProp;
6363
@@ -65,10 +65,11 @@
65 prop.type = const_cast<char *> (SmLISTofARRAY8);65 prop.type = const_cast<char *> (SmLISTofARRAY8);
6666
67 prop.vals = (SmPropValue *) malloc (nValues * sizeof (SmPropValue));67 prop.vals = (SmPropValue *) malloc (nValues * sizeof (SmPropValue));
68
68 if (!prop.vals)69 if (!prop.vals)
69 return;70 return;
7071
71 for (int i = 0; i < nValues; i++)72 for (int i = 0; i < nValues; ++i)
72 {73 {
73 prop.vals[i].value = (char *) values[i];74 prop.vals[i].value = (char *) values[i];
74 prop.vals[i].length = strlen (values[i]);75 prop.vals[i].length = strlen (values[i]);
@@ -86,20 +87,19 @@
86static void87static void
87setCloneRestartCommands (SmcConn connection)88setCloneRestartCommands (SmcConn connection)
88{89{
89 const char **args;
90
91 /* at maximum, we pass our old arguments + our new client id90 /* at maximum, we pass our old arguments + our new client id
92 to the SM, so allocate for that case */91 to the SM, so allocate for that case */
93 args = (const char **) malloc ((programArgc + 2) * sizeof (char *));92 const char **args = (const char **) malloc ((programArgc + 2) * sizeof (char *));
93
94 if (!args)94 if (!args)
95 return;95 return;
9696
97 int i, count = 0;97 int i, count = 0;
9898
99 for (i = 0; i < programArgc; i++)99 for (i = 0; i < programArgc; ++i)
100 {100 {
101 if (strcmp (programArgv[i], "--sm-client-id") == 0)101 if (strcmp (programArgv[i], "--sm-client-id") == 0)
102 i++; /* skip old client id, we'll add the new one later */102 ++i; /* skip old client id, we'll add the new one later */
103 else if (strcmp (programArgv[i], "--replace") == 0)103 else if (strcmp (programArgv[i], "--replace") == 0)
104 continue; /* there's nothing to replace when starting session */104 continue; /* there's nothing to replace when starting session */
105 else105 else
@@ -112,9 +112,10 @@
112 position 0 is the executable name */112 position 0 is the executable name */
113 for (i = count - 1; i >= 1; i--)113 for (i = count - 1; i >= 1; i--)
114 args[i + 2] = args[i];114 args[i + 2] = args[i];
115
115 args[1] = "--sm-client-id";116 args[1] = "--sm-client-id";
116 args[2] = smClientId;117 args[2] = smClientId;
117 count += 2;118 count += 2;
118119
119 setStringListProperty (connection, SmRestartCommand, args, count);120 setStringListProperty (connection, SmRestartCommand, args, count);
120121
@@ -125,14 +126,14 @@
125setRestartStyle (SmcConn connection,126setRestartStyle (SmcConn connection,
126 char hint)127 char hint)
127{128{
128 SmProp prop, *pProp;129 SmProp prop, *pProp;
129 SmPropValue propVal;130 SmPropValue propVal;
130131
131 prop.name = const_cast<char *> (SmRestartStyleHint);132 prop.name = const_cast<char *> (SmRestartStyleHint);
132 prop.type = const_cast<char *> (SmCARD8);133 prop.type = const_cast<char *> (SmCARD8);
133 prop.num_vals = 1;134 prop.num_vals = 1;
134 prop.vals = &propVal;135 prop.vals = &propVal;
135 propVal.value = &hint;136 propVal.value = &hint;
136 propVal.length = 1;137 propVal.length = 1;
137138
138 pProp = &prop;139 pProp = &prop;
@@ -141,9 +142,9 @@
141}142}
142143
143static void144static void
144setProgramInfo (SmcConn connection,145setProgramInfo (SmcConn connection,
145 pid_t pid,146 pid_t pid,
146 uid_t uid)147 uid_t uid)
147{148{
148 SmProp progProp, pidProp, userProp;149 SmProp progProp, pidProp, userProp;
149 SmPropValue progVal, pidVal, userVal;150 SmPropValue progVal, pidVal, userVal;
@@ -173,6 +174,7 @@
173 props[count++] = &pidProp;174 props[count++] = &pidProp;
174175
175 pw = getpwuid (uid);176 pw = getpwuid (uid);
177
176 if (pw)178 if (pw)
177 {179 {
178 userProp.name = const_cast<char *> (SmUserID);180 userProp.name = const_cast<char *> (SmUserID);
@@ -189,19 +191,19 @@
189}191}
190192
191static void193static void
192saveYourselfCallback (SmcConn connection,194saveYourselfCallback (SmcConn connection,
193 SmPointer client_data,195 SmPointer client_data,
194 int saveType,196 int saveType,
195 Bool shutdown,197 Bool shutdown,
196 int interact_Style,198 int interact_Style,
197 Bool fast)199 Bool fast)
198{200{
199 CompOption::Vector args;201 CompOption::Vector args;
200202
201 args.push_back (CompOption ("save_type", CompOption::TypeInt));203 args.push_back (CompOption ("save_type", CompOption::TypeInt));
202 args.push_back (CompOption ("shutdown", CompOption::TypeBool));204 args.push_back (CompOption ("shutdown", CompOption::TypeBool));
203 args.push_back (CompOption ("interact_style", CompOption::TypeInt));205 args.push_back (CompOption ("interact_style", CompOption::TypeInt));
204 args.push_back (CompOption ("fast", CompOption::TypeBool));206 args.push_back (CompOption ("fast", CompOption::TypeBool));
205207
206 args[0].value ().set (saveType);208 args[0].value ().set (saveType);
207 args[1].value ().set ((bool) shutdown);209 args[1].value ().set ((bool) shutdown);
@@ -254,13 +256,13 @@
254 callbacks.save_yourself.callback = saveYourselfCallback;256 callbacks.save_yourself.callback = saveYourselfCallback;
255 callbacks.save_yourself.client_data = NULL;257 callbacks.save_yourself.client_data = NULL;
256258
257 callbacks.die.callback = dieCallback;259 callbacks.die.callback = dieCallback;
258 callbacks.die.client_data = NULL;260 callbacks.die.client_data = NULL;
259261
260 callbacks.save_complete.callback = saveCompleteCallback;262 callbacks.save_complete.callback = saveCompleteCallback;
261 callbacks.save_complete.client_data = NULL;263 callbacks.save_complete.client_data = NULL;
262264
263 callbacks.shutdown_cancelled.callback = shutdownCancelledCallback;265 callbacks.shutdown_cancelled.callback = shutdownCancelledCallback;
264 callbacks.shutdown_cancelled.client_data = NULL;266 callbacks.shutdown_cancelled.client_data = NULL;
265267
266 smcConnection = SmcOpenConnection (NULL,268 smcConnection = SmcOpenConnection (NULL,
@@ -268,7 +270,7 @@
268 SmProtoMajor,270 SmProtoMajor,
269 SmProtoMinor,271 SmProtoMinor,
270 SmcSaveYourselfProcMask |272 SmcSaveYourselfProcMask |
271 SmcDieProcMask |273 SmcDieProcMask |
272 SmcSaveCompleteProcMask |274 SmcSaveCompleteProcMask |
273 SmcShutdownCancelledProcMask,275 SmcShutdownCancelledProcMask,
274 &callbacks,276 &callbacks,
@@ -283,10 +285,11 @@
283 else285 else
284 {286 {
285 connected = true;287 connected = true;
288
286 if (prevClientId)289 if (prevClientId)
287 smPrevClientId = strdup (prevClientId);290 smPrevClientId = strdup (prevClientId);
291
288 setRestartStyle (smcConnection, SmRestartImmediately);292 setRestartStyle (smcConnection, SmRestartImmediately);
289
290 }293 }
291 }294 }
292}295}
@@ -306,6 +309,7 @@
306 free (smClientId);309 free (smClientId);
307 smClientId = NULL;310 smClientId = NULL;
308 }311 }
312
309 if (smPrevClientId)313 if (smPrevClientId)
310 {314 {
311 free (smPrevClientId);315 free (smPrevClientId);
@@ -320,14 +324,21 @@
320 if (!connected)324 if (!connected)
321 return "";325 return "";
322326
323 switch (type) {327 switch (type)
328 {
324 case CompSession::ClientId:329 case CompSession::ClientId:
325 if (smClientId)330 if (smClientId)
326 return smClientId;331 return smClientId;
332
327 break;333 break;
334
328 case CompSession::PrevClientId:335 case CompSession::PrevClientId:
329 if (smPrevClientId)336 if (smPrevClientId)
330 return smPrevClientId;337 return smPrevClientId;
338
339 break;
340
341 default:
331 break;342 break;
332 }343 }
333344
@@ -341,11 +352,9 @@
341static bool352static bool
342iceProcessMessages (IceConn connection)353iceProcessMessages (IceConn connection)
343{354{
344 IceProcessMessagesStatus status;
345
346 SM_DEBUG (printf ("ICE connection process messages\n"));355 SM_DEBUG (printf ("ICE connection process messages\n"));
347356
348 status = IceProcessMessages (connection, NULL, NULL);357 IceProcessMessagesStatus status = IceProcessMessages (connection, NULL, NULL);
349358
350 if (status == IceProcessMessagesIOError)359 if (status == IceProcessMessagesIOError)
351 {360 {

Subscribers

People subscribed via source and target branches

to all changes: