cmptr = malloc (controllen);
if (NULL == cmptr) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
ssize_t n = recvmsg (s, &msg, 0);
if (n < 0) {
perror ("recvmsg stdout fd");
- exit (1);
+ exit (EXIT_FAILURE);
}
h = CMSG_FIRSTHDR(&msg);
else {
/* Extract the transferred file descriptor from the control data */
- int fd = *(int *)CMSG_DATA (h);
+ unsigned char *data = CMSG_DATA (h);
+ int fd = *(int *)data;
/* Duplicate the received file descriptor to stdout */
dup2 (fd, STDOUT_FILENO);
cmptr = malloc (controllen);
if (NULL == cmptr) {
perror ("malloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
cmptr->cmsg_level = SOL_SOCKET;
msg.msg_controllen = controllen;
/* Add STDOUT to the control data */
- *(int *)CMSG_DATA (cmptr) = STDOUT_FILENO;
+ unsigned char *data = CMSG_DATA (cmptr);
+ *(int *)data = STDOUT_FILENO;
if (sendmsg (s, &msg, 0) != 1) {
perror ("sendmsg stdout fd");
- exit (1);
+ exit (EXIT_FAILURE);
}
}
pid = fork ();
if (pid == -1) {
perror ("fork");
- exit (1);
+ exit (EXIT_FAILURE);
}
if (pid > 0) {
sock = socket (AF_UNIX, SOCK_STREAM, 0);
if (sock == -1) {
perror ("socket");
- exit (1);
+ exit (EXIT_FAILURE);
}
unlink (sockpath);
if (bind (sock, (struct sockaddr *) &addr, sizeof addr) == -1) {
perror (sockpath);
- exit (1);
+ exit (EXIT_FAILURE);
}
if (listen (sock, 4) == -1) {
perror ("listen");
- exit (1);
+ exit (EXIT_FAILURE);
}
/* Now close stdout and substitute /dev/null. This is necessary
goto error;
}
- if (strcmp (hello.vers, PACKAGE_VERSION) != 0) {
+ if (STRNEQ (hello.vers, PACKAGE_VERSION)) {
fprintf (stderr, _("guestfish: protocol error: version mismatch, server version '%s' does not match client version '%s'. The two versions must match exactly.\n"),
PACKAGE_VERSION,
hello.vers);
argv = realloc (call.args.args_val, (argc+1) * sizeof (char *));
if (argv == NULL) {
perror ("realloc");
- exit (1);
+ exit (EXIT_FAILURE);
}
call.args.args_val = argv;
argv[argc] = NULL;
/* Exit on error? */
if (call.exit_on_error && reply.r == -1) {
unlink (sockpath);
- exit (1);
+ exit (EXIT_FAILURE);
}
}
}
unlink (sockpath);
- exit (0);
+ exit (EXIT_SUCCESS);
}
/* Remote control client. */