xquartz: Fix some formatting

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston Sequoia 2022-12-14 00:13:34 -08:00
parent 3fd87692e8
commit f73c489771
Failed to extract signature

View File

@ -60,15 +60,13 @@ aslclient aslc;
static void static void
set_x11_path(void) set_x11_path(void)
{ {
OSStatus osstatus = OSStatus osstatus = LSFindApplicationForInfo(kLSUnknownCreator, CFSTR(kX11AppBundleId),
LSFindApplicationForInfo(kLSUnknownCreator, CFSTR( nil, &x11_appRef, &x11appURL);
kX11AppBundleId), nil, &x11_appRef, &x11appURL);
switch (osstatus) { switch (osstatus) {
case noErr: case noErr:
if (x11appURL == NULL) { if (x11appURL == NULL) {
asl_log( asl_log(aslc, NULL, ASL_LEVEL_ERR,
aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Invalid response from LSFindApplicationForInfo(%s)", "Xquartz: Invalid response from LSFindApplicationForInfo(%s)",
kX11AppBundleId); kX11AppBundleId);
exit(1); exit(1);
@ -84,8 +82,7 @@ set_x11_path(void)
default: default:
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Unable to find application for %s, error code = %d", "Xquartz: Unable to find application for %s, error code = %d",
kX11AppBundleId, kX11AppBundleId, (int)osstatus);
(int)osstatus);
exit(11); exit(11);
} }
} }
@ -110,18 +107,15 @@ connect_to_socket(const char *filename)
ret_fd = socket(PF_UNIX, SOCK_STREAM, 0); ret_fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (ret_fd == -1) { if (ret_fd == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to create socket: %s - %s", filename, "Xquartz: Failed to create socket: %s - %d - %s",
strerror( filename, errno, strerror(errno));
errno));
return -1; return -1;
} }
if (connect(ret_fd, servaddr, servaddr_len) < 0) { if (connect(ret_fd, servaddr, servaddr_len) < 0) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to connect to socket: %s - %d - %s", "Xquartz: Failed to connect to socket: %s - %d - %s",
filename, errno, filename, errno, strerror(errno));
strerror(
errno));
close(ret_fd); close(ret_fd);
return -1; return -1;
} }
@ -164,8 +158,7 @@ send_fd_handoff(int connected_fd, int launchd_fd)
*((int *)CMSG_DATA(cmsg)) = launchd_fd; *((int *)CMSG_DATA(cmsg)) = launchd_fd;
if (sendmsg(connected_fd, &msg, 0) < 0) { if (sendmsg(connected_fd, &msg, 0) < 0) {
asl_log( asl_log(aslc, NULL, ASL_LEVEL_ERR,
aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s", "Xquartz: Error sending $DISPLAY file descriptor over fd %d: %d -- %s",
connected_fd, errno, strerror(errno)); connected_fd, errno, strerror(errno));
return; return;
@ -270,8 +263,7 @@ main(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: bootstrap_look_up(): %s", bootstrap_strerror( "Xquartz: bootstrap_look_up(): %s", bootstrap_strerror(kr));
kr));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} }
@ -285,11 +277,8 @@ main(int argc, char **argv, char **envp)
int handoff_fd = -1; int handoff_fd = -1;
for (try = 0, try_max = 5; try < try_max; try++) { for (try = 0, try_max = 5; try < try_max; try++) {
if (request_fd_handoff_socket(mp, if (request_fd_handoff_socket(mp, handoff_socket_filename) != KERN_SUCCESS) {
handoff_socket_filename) != asl_log(aslc, NULL, ASL_LEVEL_INFO,
KERN_SUCCESS) {
asl_log(
aslc, NULL, ASL_LEVEL_INFO,
"Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)", "Xquartz: Failed to request a socket from the server to send the $DISPLAY fd over (try %d of %d)",
(int)try + 1, (int)try_max); (int)try + 1, (int)try_max);
continue; continue;
@ -299,16 +288,13 @@ main(int argc, char **argv, char **envp)
if (handoff_fd == -1) { if (handoff_fd == -1) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Failed to connect to socket (try %d of %d)", "Xquartz: Failed to connect to socket (try %d of %d)",
(int)try + 1, (int)try + 1, (int)try_max);
(int)try_max);
continue; continue;
} }
asl_log( asl_log(aslc, NULL, ASL_LEVEL_INFO,
aslc, NULL, ASL_LEVEL_INFO,
"Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.", "Xquartz: Handoff connection established (try %d of %d) on fd %d, \"%s\". Sending message.",
(int)try + 1, (int)try_max, handoff_fd, (int)try + 1, (int)try_max, handoff_fd, handoff_socket_filename);
handoff_socket_filename);
send_fd_handoff(handoff_fd, launchd_fd); send_fd_handoff(handoff_fd, launchd_fd);
close(handoff_fd); close(handoff_fd);
break; break;
@ -329,8 +315,7 @@ main(int argc, char **argv, char **envp)
free(newargv); free(newargv);
free(newenvp); free(newenvp);
asl_log(aslc, NULL, ASL_LEVEL_ERR, asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: Memory allocation failure");
"Xquartz: Memory allocation failure");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -348,8 +333,7 @@ main(int argc, char **argv, char **envp)
if (kr != KERN_SUCCESS) { if (kr != KERN_SUCCESS) {
asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s", asl_log(aslc, NULL, ASL_LEVEL_ERR, "Xquartz: start_x11_server: %s",
mach_error_string( mach_error_string(kr));
kr));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;