tools: put bin_PROGRAMS one per line, eliminate unnecessary variable
[platform/upstream/dbus.git] / tools / dbus-launch.c
index d3553e8..bbaac2c 100644 (file)
@@ -21,6 +21,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
+
+#include <config.h>
 #include "dbus-launch.h"
 #include <stdlib.h>
 #include <ctype.h>
@@ -363,9 +365,9 @@ print_variables (const char *bus_address, pid_t bus_pid, long bus_wid,
 {
   if (binary_syntax)
     {
-      write (1, bus_address, strlen (bus_address) + 1);
-      write (1, &bus_pid, sizeof bus_pid);
-      write (1, &bus_wid, sizeof bus_wid);
+      do_write (1, bus_address, strlen (bus_address) + 1);
+      do_write (1, &bus_pid, sizeof bus_pid);
+      do_write (1, &bus_wid, sizeof bus_wid);
       return;
     }
   else if (c_shell_syntax)
@@ -688,10 +690,11 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid,
            int binary_syntax,
            int argc, char **argv, int remaining_args)
 {
+  char *envvar = NULL;
+  char **args = NULL;
+
   if (runprog)
     {
-      char *envvar;
-      char **args;
       int i;
 
       envvar = malloc (strlen ("DBUS_SESSION_BUS_ADDRESS=") +
@@ -735,6 +738,12 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid,
   close (2);
   exit (0);
 oom:
+  if (envvar)
+    free (envvar);
+
+  if (args)
+    free (args);
+
   fprintf (stderr, "Out of memory!");
   exit (1);
 }
@@ -908,7 +917,11 @@ main (int argc, char **argv)
       fprintf (stderr, "Autolaunch requested, but X11 support not compiled in.\n"
               "Cannot continue.\n");
       exit (1);
-#else
+#else /* DBUS_BUILD_X11 */
+#ifndef DBUS_ENABLE_X11_AUTOLAUNCH
+      fprintf (stderr, "X11 autolaunch support disabled at compile time.\n");
+      exit (1);
+#else /* DBUS_ENABLE_X11_AUTOLAUNCH */
       char *address;
       pid_t pid;
       long wid;
@@ -945,11 +958,12 @@ main (int argc, char **argv)
                           bourne_shell_syntax, binary_syntax, argc, argv, remaining_args);
          exit (0);
        }
+#endif /* DBUS_ENABLE_X11_AUTOLAUNCH */
     }
-   else if (read_machine_uuid_if_needed())
+  else if (read_machine_uuid_if_needed())
     {
       x11_init();
-#endif
+#endif /* DBUS_BUILD_X11 */
     }
 
 
@@ -1168,7 +1182,7 @@ main (int argc, char **argv)
 
       close (bus_pid_to_launcher_pipe[READ_END]);
 
-#ifdef DBUS_BUILD_X11
+#ifdef DBUS_ENABLE_X11_AUTOLAUNCH
       if (xdisplay != NULL)
         {
           verbose("Saving x11 address\n");