<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[23143] trunk/launchd/src/launchctl.c</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/launchd/changeset/23143">23143</a></dd>
<dt>Author</dt> <dd>zarzycki@apple.com</dd>
<dt>Date</dt> <dd>2007-03-07 10:01:26 -0800 (Wed, 07 Mar 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>Wow, I don't touch launchctl.c enough. My style has changed over time.

(Always use {}, you're going to need them eventually, and when you do, it makes for a more clear diff.)</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunklaunchdsrclaunchctlc">trunk/launchd/src/launchctl.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunklaunchdsrclaunchctlc"></a>
<div class="modfile"><h4>Modified: trunk/launchd/src/launchctl.c (23142 => 23143)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/launchd/src/launchctl.c        2007-03-07 17:44:28 UTC (rev 23142)
+++ trunk/launchd/src/launchctl.c        2007-03-07 18:01:26 UTC (rev 23143)
</span><span class="lines">@@ -278,8 +278,9 @@
</span><span class="cx">         optreset = 1;
</span><span class="cx"> 
</span><span class="cx">         for (i = 0; i &lt; (sizeof cmds / sizeof cmds[0]); i++) {
</span><del>-                if (!strcmp(cmds[i].name, argv[0]))
</del><ins>+                if (!strcmp(cmds[i].name, argv[0])) {
</ins><span class="cx">                         return cmds[i].func(argc, argv);
</span><ins>+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         fprintf(stderr, &quot;%s: unknown subcommand \&quot;%s\&quot;\n&quot;, getprogname(), argv[0]);
</span><span class="lines">@@ -349,10 +350,11 @@
</span><span class="cx">         bool *is_csh = context;
</span><span class="cx"> 
</span><span class="cx">         /* XXX escape the double quotes */
</span><del>-        if (*is_csh)
</del><ins>+        if (*is_csh) {
</ins><span class="cx">                 fprintf(stdout, &quot;setenv %s \&quot;%s\&quot;;\n&quot;, key, launch_data_get_string(obj));
</span><del>-        else
</del><ins>+        } else {
</ins><span class="cx">                 fprintf(stdout, &quot;%s=\&quot;%s\&quot;; export %s;\n&quot;, key, launch_data_get_string(obj), key);
</span><ins>+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void
</span><span class="lines">@@ -360,8 +362,9 @@
</span><span class="cx"> {
</span><span class="cx">         const char *k = context;
</span><span class="cx"> 
</span><del>-        if (!strcmp(key, k))
</del><ins>+        if (!strcmp(key, k)) {
</ins><span class="cx">                 fprintf(stdout, &quot;%s\n&quot;, launch_data_get_string(obj));
</span><ins>+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int
</span><span class="lines">@@ -373,8 +376,9 @@
</span><span class="cx">         
</span><span class="cx">         if (!strcmp(argv[0], &quot;export&quot;)) {
</span><span class="cx">                 char *s = getenv(&quot;SHELL&quot;);
</span><del>-                if (s)
</del><ins>+                if (s) {
</ins><span class="cx">                         is_csh = strstr(s, &quot;csh&quot;) ? true : false;
</span><ins>+                }
</ins><span class="cx">         } else if (argc != 2) {
</span><span class="cx">                 fprintf(stderr, &quot;%s usage: getenv &lt;key&gt;\n&quot;, getprogname());
</span><span class="cx">                 return 1;
</span><span class="lines">@@ -388,10 +392,11 @@
</span><span class="cx">         launch_data_free(msg);
</span><span class="cx"> 
</span><span class="cx">         if (resp) {
</span><del>-                if (!strcmp(argv[0], &quot;export&quot;))
</del><ins>+                if (!strcmp(argv[0], &quot;export&quot;)) {
</ins><span class="cx">                         launch_data_dict_iterate(resp, print_launchd_env, &amp;is_csh);
</span><del>-                else
</del><ins>+                } else {
</ins><span class="cx">                         launch_data_dict_iterate(resp, print_key_value, k);
</span><ins>+                }
</ins><span class="cx">                 launch_data_free(resp);
</span><span class="cx">         } else {
</span><span class="cx">                 fprintf(stderr, &quot;launch_msg(\&quot;&quot; LAUNCH_KEY_GETUSERENVIRONMENT &quot;\&quot;): %s\n&quot;, strerror(errno));
</span><span class="lines">@@ -423,8 +428,9 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">         if (LAUNCH_DATA_ERRNO == launch_data_get_type(resp)) {
</span><del>-                if ((e = launch_data_get_errno(resp)))
</del><ins>+                if ((e = launch_data_get_errno(resp))) {
</ins><span class="cx">                         fprintf(stderr, &quot;%s\n&quot;, strerror(e));
</span><ins>+                }
</ins><span class="cx">         }
</span><span class="cx">         launch_data_free(resp);
</span><span class="cx"> }
</span><span class="lines">@@ -441,10 +447,11 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (editondisk) {
</span><del>-                if (load)
</del><ins>+                if (load) {
</ins><span class="cx">                         CFDictionaryRemoveValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED));
</span><del>-                else
</del><ins>+                } else {
</ins><span class="cx">                         CFDictionarySetValue((CFMutableDictionaryRef)plist, CFSTR(LAUNCH_JOBKEY_DISABLED), kCFBooleanTrue);
</span><ins>+                }
</ins><span class="cx">                 WriteMyPropertyListToFile(plist, file);
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -471,8 +478,9 @@
</span><span class="cx">                 launch_data_dict_iterate(o, delay_to_second_pass2, context);
</span><span class="cx">                 break;
</span><span class="cx">         case LAUNCH_DATA_ARRAY:
</span><del>-                for (i = 0; i &lt; launch_data_array_get_count(o); i++)
</del><ins>+                for (i = 0; i &lt; launch_data_array_get_count(o); i++) {
</ins><span class="cx">                         delay_to_second_pass2(launch_data_array_get_index(o, i), NULL, context);
</span><ins>+                }
</ins><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="cx">                 break;
</span><span class="lines">@@ -486,8 +494,9 @@
</span><span class="cx"> 
</span><span class="cx">         launch_data_t socks = launch_data_dict_lookup(o, LAUNCH_JOBKEY_SOCKETS);
</span><span class="cx"> 
</span><del>-        if (NULL == socks)
</del><ins>+        if (NULL == socks) {
</ins><span class="cx">                 return false;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         delay_to_second_pass2(socks, NULL, &amp;res);
</span><span class="cx"> 
</span><span class="lines">@@ -525,8 +534,9 @@
</span><span class="cx"> 
</span><span class="cx">                 for (i = 0; i &lt; c; i++) {
</span><span class="cx">                         launch_data_t oai = launch_data_array_get_index(tmpa, i);
</span><del>-                        if (!strcasecmp(ourhostname, launch_data_get_string(oai)))
</del><ins>+                        if (!strcasecmp(ourhostname, launch_data_get_string(oai))) {
</ins><span class="cx">                                 goto out_bad;
</span><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -535,12 +545,14 @@
</span><span class="cx"> 
</span><span class="cx">                 for (i = 0; i &lt; c; i++) {
</span><span class="cx">                         launch_data_t oai = launch_data_array_get_index(tmpa, i);
</span><del>-                        if (!strcasecmp(ourhostname, launch_data_get_string(oai)))
</del><ins>+                        if (!strcasecmp(ourhostname, launch_data_get_string(oai))) {
</ins><span class="cx">                                 break;
</span><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if (i == c)
</del><ins>+                if (i == c) {
</ins><span class="cx">                         goto out_bad;
</span><ins>+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (lus-&gt;session_type &amp;&amp; !(tmpa = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_LIMITLOADTOSESSIONTYPE))) {
</span><span class="lines">@@ -582,27 +594,33 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ((tmpd = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_DISABLED)))
</del><ins>+        if ((tmpd = launch_data_dict_lookup(thejob, LAUNCH_JOBKEY_DISABLED))) {
</ins><span class="cx">                 job_disabled = launch_data_get_bool(tmpd);
</span><ins>+        }
</ins><span class="cx"> 
</span><del>-        if (lus-&gt;forceload)
</del><ins>+        if (lus-&gt;forceload) {
</ins><span class="cx">                 job_disabled = false;
</span><ins>+        }
</ins><span class="cx"> 
</span><del>-        if (job_disabled &amp;&amp; lus-&gt;load)
</del><ins>+        if (job_disabled &amp;&amp; lus-&gt;load) {
</ins><span class="cx">                 goto out_bad;
</span><ins>+        }
</ins><span class="cx"> 
</span><del>-        if (delay_to_second_pass(thejob))
</del><ins>+        if (delay_to_second_pass(thejob)) {
</ins><span class="cx">                 launch_data_array_append(lus-&gt;pass2, thejob);
</span><del>-        else
</del><ins>+        } else {
</ins><span class="cx">                 launch_data_array_append(lus-&gt;pass1, thejob);
</span><ins>+        }
</ins><span class="cx"> 
</span><del>-        if (verbose)
</del><ins>+        if (verbose) {
</ins><span class="cx">                 fprintf(stdout, &quot;Will load: %s\n&quot;, what);
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         return;
</span><span class="cx"> out_bad:
</span><del>-        if (verbose)
</del><ins>+        if (verbose) {
</ins><span class="cx">                 fprintf(stdout, &quot;Ignored: %s\n&quot;, what);
</span><ins>+        }
</ins><span class="cx">         launch_data_free(thejob);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -616,8 +634,9 @@
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (forceload)
</del><ins>+        if (forceload) {
</ins><span class="cx">                 return true;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (sb.st_mode &amp; (S_IWOTH|S_IWGRP)) {
</span><span class="cx">                 fprintf(stderr, &quot;%s: Dubious permissions on file (skipping): %s\n&quot;, getprogname(), path);
</span><span class="lines">@@ -645,11 +664,13 @@
</span><span class="cx">         struct dirent *de;
</span><span class="cx">         DIR *d;
</span><span class="cx"> 
</span><del>-        if (!path_goodness_check(what, lus-&gt;forceload))
</del><ins>+        if (!path_goodness_check(what, lus-&gt;forceload)) {
</ins><span class="cx">                 return;
</span><ins>+        }
</ins><span class="cx"> 
</span><del>-        if (stat(what, &amp;sb) == -1)
</del><ins>+        if (stat(what, &amp;sb) == -1) {
</ins><span class="cx">                 return;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (S_ISREG(sb.st_mode)) {
</span><span class="cx">                 readfile(what, lus);
</span><span class="lines">@@ -660,12 +681,14 @@
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 while ((de = readdir(d))) {
</span><del>-                        if ((de-&gt;d_name[0] == '.'))
</del><ins>+                        if ((de-&gt;d_name[0] == '.')) {
</ins><span class="cx">                                 continue;
</span><ins>+                        }
</ins><span class="cx">                         snprintf(buf, sizeof(buf), &quot;%s/%s&quot;, what, de-&gt;d_name);
</span><span class="cx"> 
</span><del>-                        if (!path_goodness_check(buf, lus-&gt;forceload))
</del><ins>+                        if (!path_goodness_check(buf, lus-&gt;forceload)) {
</ins><span class="cx">                                 continue;
</span><ins>+                        }
</ins><span class="cx"> 
</span><span class="cx">                         readfile(buf, lus);
</span><span class="cx">                 }
</span><span class="lines">@@ -738,8 +761,9 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_PASSIVE)))
</del><ins>+        if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_PASSIVE))) {
</ins><span class="cx">                 passive = launch_data_get_bool(val);
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_SECUREWITHKEY))) {
</span><span class="cx">                 char secdir[] = LAUNCH_SECDIR, buf[1024];
</span><span class="lines">@@ -772,8 +796,9 @@
</span><span class="cx"> 
</span><span class="cx">                 strncpy(sun.sun_path, launch_data_get_string(val), sizeof(sun.sun_path));
</span><span class="cx">         
</span><del>-                if ((sfd = _fd(socket(AF_UNIX, st, 0))) == -1)
</del><ins>+                if ((sfd = _fd(socket(AF_UNIX, st, 0))) == -1) {
</ins><span class="cx">                         return;
</span><ins>+                }
</ins><span class="cx"> 
</span><span class="cx">                 if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_PATHMODE))) {
</span><span class="cx">                         sun_mode = (mode_t)launch_data_get_integer(val);
</span><span class="lines">@@ -795,8 +820,7 @@
</span><span class="cx">                         if (setm) {
</span><span class="cx">                                 chmod(sun.sun_path, sun_mode);
</span><span class="cx">                         }
</span><del>-                        if ((st == SOCK_STREAM || st == SOCK_SEQPACKET)
-                                        &amp;&amp; listen(sfd, SOMAXCONN) == -1) {
</del><ins>+                        if ((st == SOCK_STREAM || st == SOCK_SEQPACKET) &amp;&amp; listen(sfd, SOMAXCONN) == -1) {
</ins><span class="cx">                                 close(sfd);
</span><span class="cx">                                 return;
</span><span class="cx">                         }
</span><span class="lines">@@ -818,13 +842,16 @@
</span><span class="cx">                 memset(&amp;hints, 0, sizeof(hints));
</span><span class="cx"> 
</span><span class="cx">                 hints.ai_socktype = st;
</span><del>-                if (passive)
</del><ins>+                if (passive) {
</ins><span class="cx">                         hints.ai_flags |= AI_PASSIVE;
</span><ins>+                }
</ins><span class="cx"> 
</span><del>-                if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_NODENAME)))
</del><ins>+                if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_NODENAME))) {
</ins><span class="cx">                         node = launch_data_get_string(val);
</span><del>-                if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_MULTICASTGROUP)))
</del><ins>+                }
+                if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_MULTICASTGROUP))) {
</ins><span class="cx">                         mgroup = launch_data_get_string(val);
</span><ins>+                }
</ins><span class="cx">                 if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_SERVICENAME))) {
</span><span class="cx">                         if (LAUNCH_DATA_INTEGER == launch_data_get_type(val)) {
</span><span class="cx">                                 sprintf(servnbuf, &quot;%lld&quot;, launch_data_get_integer(val));
</span><span class="lines">@@ -834,10 +861,11 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_FAMILY))) {
</span><del>-                        if (!strcasecmp(&quot;IPv4&quot;, launch_data_get_string(val)))
</del><ins>+                        if (!strcasecmp(&quot;IPv4&quot;, launch_data_get_string(val))) {
</ins><span class="cx">                                 hints.ai_family = AF_INET;
</span><del>-                        else if (!strcasecmp(&quot;IPv6&quot;, launch_data_get_string(val)))
</del><ins>+                        } else if (!strcasecmp(&quot;IPv6&quot;, launch_data_get_string(val))) {
</ins><span class="cx">                                 hints.ai_family = AF_INET6;
</span><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">                 if ((val = launch_data_dict_lookup(tmp, LAUNCH_JOBSOCKETKEY_PROTOCOL))) {
</span><span class="cx">                         if (!strcasecmp(&quot;TCP&quot;, launch_data_get_string(val))) {
</span><span class="lines">@@ -900,8 +928,7 @@
</span><span class="cx">                                 if (mgroup) {
</span><span class="cx">                                         do_mgroup_join(sfd, res-&gt;ai_family, res-&gt;ai_socktype, res-&gt;ai_protocol, mgroup);
</span><span class="cx">                                 }
</span><del>-                                if ((res-&gt;ai_socktype == SOCK_STREAM || res-&gt;ai_socktype == SOCK_SEQPACKET)
-                                                &amp;&amp; listen(sfd, SOMAXCONN) == -1) {
</del><ins>+                                if ((res-&gt;ai_socktype == SOCK_STREAM || res-&gt;ai_socktype == SOCK_SEQPACKET) &amp;&amp; listen(sfd, SOMAXCONN) == -1) {
</ins><span class="cx">                                         fprintf(stderr, &quot;listen(): %s\n&quot;, strerror(errno));
</span><span class="cx">                                         return;
</span><span class="cx">                                 }
</span><span class="lines">@@ -914,12 +941,14 @@
</span><span class="cx">                                         }
</span><span class="cx">                                         if (NULL == rnames) {
</span><span class="cx">                                                 rvs_fd = do_rendezvous_magic(res, serv);
</span><del>-                                                if (rvs_fd)
</del><ins>+                                                if (rvs_fd) {
</ins><span class="cx">                                                         launch_data_array_append(rvs_fds, rvs_fd);
</span><ins>+                                                }
</ins><span class="cx">                                         } else if (LAUNCH_DATA_STRING == launch_data_get_type(rnames)) {
</span><span class="cx">                                                 rvs_fd = do_rendezvous_magic(res, launch_data_get_string(rnames));
</span><del>-                                                if (rvs_fd)
</del><ins>+                                                if (rvs_fd) {
</ins><span class="cx">                                                         launch_data_array_append(rvs_fds, rvs_fd);
</span><ins>+                                                }
</ins><span class="cx">                                         } else if (LAUNCH_DATA_ARRAY == launch_data_get_type(rnames)) {
</span><span class="cx">                                                 size_t rn_i, rn_ac = launch_data_array_get_count(rnames);
</span><span class="cx"> 
</span><span class="lines">@@ -927,8 +956,9 @@
</span><span class="cx">                                                         launch_data_t rn_tmp = launch_data_array_get_index(rnames, rn_i);
</span><span class="cx"> 
</span><span class="cx">                                                         rvs_fd = do_rendezvous_magic(res, launch_data_get_string(rn_tmp));
</span><del>-                                                        if (rvs_fd)
</del><ins>+                                                        if (rvs_fd) {
</ins><span class="cx">                                                                 launch_data_array_append(rvs_fds, rvs_fd);
</span><ins>+                                                        }
</ins><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="lines">@@ -1006,23 +1036,27 @@
</span><span class="cx">         short port;
</span><span class="cx">         static int statres = 1;
</span><span class="cx"> 
</span><del>-        if (1 == statres)
</del><ins>+        if (1 == statres) {
</ins><span class="cx">                 statres = stat(&quot;/usr/sbin/mDNSResponder&quot;, &amp;sb);
</span><ins>+        }
</ins><span class="cx"> 
</span><del>-        if (-1 == statres)
</del><ins>+        if (-1 == statres) {
</ins><span class="cx">                 return NULL;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         sprintf(rvs_buf, &quot;_%s._%s.&quot;, serv, res-&gt;ai_socktype == SOCK_STREAM ? &quot;tcp&quot; : &quot;udp&quot;);
</span><span class="cx"> 
</span><del>-        if (res-&gt;ai_family == AF_INET)
</del><ins>+        if (res-&gt;ai_family == AF_INET) {
</ins><span class="cx">                 port = ((struct sockaddr_in *)res-&gt;ai_addr)-&gt;sin_port;
</span><del>-        else
</del><ins>+        } else {
</ins><span class="cx">                 port = ((struct sockaddr_in6 *)res-&gt;ai_addr)-&gt;sin6_port;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         error = DNSServiceRegister(&amp;service, 0, 0, NULL, rvs_buf, NULL, NULL, port, 0, NULL, NULL, NULL);
</span><span class="cx"> 
</span><del>-        if (error == kDNSServiceErr_NoError)
</del><ins>+        if (error == kDNSServiceErr_NoError) {
</ins><span class="cx">                 return launch_data_new_fd(DNSServiceRefSockFD(service));
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         fprintf(stderr, &quot;DNSServiceRegister(\&quot;%s\&quot;): %d\n&quot;, serv, error);
</span><span class="cx">         return NULL;
</span><span class="lines">@@ -1038,13 +1072,16 @@
</span><span class="cx">         CFURLRef          fileURL;
</span><span class="cx"> 
</span><span class="cx">         fileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)posixfile, strlen(posixfile), false);
</span><del>-        if (!fileURL)
</del><ins>+        if (!fileURL) {
</ins><span class="cx">                 fprintf(stderr, &quot;%s: CFURLCreateFromFileSystemRepresentation(%s) failed\n&quot;, getprogname(), posixfile);
</span><del>-        if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, fileURL, &amp;resourceData, NULL, NULL, &amp;errorCode))
</del><ins>+        }
+        if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, fileURL, &amp;resourceData, NULL, NULL, &amp;errorCode)) {
</ins><span class="cx">                 fprintf(stderr, &quot;%s: CFURLCreateDataAndPropertiesFromResource(%s) failed: %d\n&quot;, getprogname(), posixfile, (int)errorCode);
</span><ins>+        }
</ins><span class="cx">         propertyList = CFPropertyListCreateFromXMLData(kCFAllocatorDefault, resourceData, kCFPropertyListMutableContainers, &amp;errorString);
</span><del>-        if (!propertyList)
</del><ins>+        if (!propertyList) {
</ins><span class="cx">                 fprintf(stderr, &quot;%s: propertyList is NULL\n&quot;, getprogname());
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         return propertyList;
</span><span class="cx"> }
</span><span class="lines">@@ -1057,13 +1094,16 @@
</span><span class="cx">         SInt32                errorCode;
</span><span class="cx"> 
</span><span class="cx">         fileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)posixfile, strlen(posixfile), false);
</span><del>-        if (!fileURL)
</del><ins>+        if (!fileURL) {
</ins><span class="cx">                 fprintf(stderr, &quot;%s: CFURLCreateFromFileSystemRepresentation(%s) failed\n&quot;, getprogname(), posixfile);
</span><ins>+        }
</ins><span class="cx">         resourceData = CFPropertyListCreateXMLData(kCFAllocatorDefault, plist);
</span><del>-        if (resourceData == NULL)
</del><ins>+        if (resourceData == NULL) {
</ins><span class="cx">                 fprintf(stderr, &quot;%s: CFPropertyListCreateXMLData(%s) failed&quot;, getprogname(), posixfile);
</span><del>-        if (!CFURLWriteDataAndPropertiesToResource(fileURL, resourceData, NULL, &amp;errorCode))
</del><ins>+        }
+        if (!CFURLWriteDataAndPropertiesToResource(fileURL, resourceData, NULL, &amp;errorCode)) {
</ins><span class="cx">                 fprintf(stderr, &quot;%s: CFURLWriteDataAndPropertiesToResource(%s) failed: %d\n&quot;, getprogname(), posixfile, (int)errorCode);
</span><ins>+        }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void
</span><span class="lines">@@ -1162,8 +1202,9 @@
</span><span class="cx">                         cmdwidth = l;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        for (i = 0; i &lt; (sizeof cmds / sizeof cmds[0]); i++)
</del><ins>+        for (i = 0; i &lt; (sizeof cmds / sizeof cmds[0]); i++) {
</ins><span class="cx">                 fprintf(where, &quot;\t%-*s\t%s\n&quot;, cmdwidth, cmds[i].name, cmds[i].desc);
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -1564,10 +1605,12 @@
</span><span class="cx">                 distill_jobs(lus.pass2);
</span><span class="cx">                 submit_job_pass(lus.pass2);
</span><span class="cx">         } else {
</span><del>-                for (i = 0; i &lt; launch_data_array_get_count(lus.pass1); i++)
</del><ins>+                for (i = 0; i &lt; launch_data_array_get_count(lus.pass1); i++) {
</ins><span class="cx">                         unloadjob(launch_data_array_get_index(lus.pass1, i));
</span><del>-                for (i = 0; i &lt; launch_data_array_get_count(lus.pass2); i++)
</del><ins>+                }
+                for (i = 0; i &lt; launch_data_array_get_count(lus.pass2); i++) {
</ins><span class="cx">                         unloadjob(launch_data_array_get_index(lus.pass2, i));
</span><ins>+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return 0;
</span><span class="lines">@@ -2762,18 +2805,21 @@
</span><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">         while ((val = fgetln(sf, &amp;ln_len))) {
</span><del>-                if (ln_len == 0)
</del><ins>+                if (ln_len == 0) {
</ins><span class="cx">                         continue;
</span><del>-                if (!assumes((tmpstr = malloc(ln_len + 1)) != NULL))
</del><ins>+                }
+                if (!assumes((tmpstr = malloc(ln_len + 1)) != NULL)) {
</ins><span class="cx">                         continue;
</span><ins>+                }
</ins><span class="cx">                 memcpy(tmpstr, val, ln_len);
</span><span class="cx">                 tmpstr[ln_len] = 0;
</span><span class="cx">                 val = tmpstr;
</span><span class="cx"> 
</span><span class="cx">                 while (*val &amp;&amp; isspace(*val))
</span><span class="cx">                         val++;
</span><del>-                if (*val == '\0' || *val == '#')
</del><ins>+                if (*val == '\0' || *val == '#') {
</ins><span class="cx">                         goto skip_sysctl_tool;
</span><ins>+                }
</ins><span class="cx">                 sysctl_tool[2] = val;
</span><span class="cx">                 assumes(fwexec(sysctl_tool, true) != -1);
</span><span class="cx"> skip_sysctl_tool:
</span><span class="lines">@@ -2799,8 +2845,9 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (buf[0] != '\0')
</del><ins>+        if (buf[0] != '\0') {
</ins><span class="cx">                 return;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         versdict = _CFCopySystemVersionDictionary();
</span><span class="cx">         buildvers = CFDictionaryGetValue(versdict, _kCFSystemVersionBuildVersionKey);
</span></span></pre>
</div>
</div>

</body>
</html>