Unify error message formating

This commit is contained in:
Martin Lund 2022-06-11 23:36:51 +02:00
parent bf749aead4
commit 0a892006ea
2 changed files with 8 additions and 8 deletions

View file

@ -173,21 +173,21 @@ void socket_configure(void)
sockfd = socket(socket_family, SOCK_STREAM, 0); sockfd = socket(socket_family, SOCK_STREAM, 0);
if (sockfd < 0) if (sockfd < 0)
{ {
error_printf("Failed to create socket: %s", strerror(errno)); error_printf("Failed to create socket (%s)", strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Bind */ /* Bind */
if (bind(sockfd, sockaddr_p, socklen) < 0) if (bind(sockfd, sockaddr_p, socklen) < 0)
{ {
error_printf("Failed to bind to socket %s", strerror(errno)); error_printf("Failed to bind to socket (%s)", strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Listen */ /* Listen */
if (listen(sockfd, MAX_SOCKET_CLIENTS) < 0) if (listen(sockfd, MAX_SOCKET_CLIENTS) < 0)
{ {
error_printf("Failed to listen on socket %s", strerror(errno)); error_printf("Failed to listen on socket (%s)", strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -217,7 +217,7 @@ void socket_write(char input_char)
{ {
if (write(clientfds[i], &input_char, 1) <= 0) if (write(clientfds[i], &input_char, 1) <= 0)
{ {
error_printf_silent("Failed to write to socket: %s", strerror(errno)); error_printf_silent("Failed to write to socket (%s)", strerror(errno));
close(clientfds[i]); close(clientfds[i]);
clientfds[i] = -1; clientfds[i] = -1;
} }
@ -288,7 +288,7 @@ bool socket_handle_input(fd_set *rdfs, char *output_char)
} }
if (status < 0) if (status < 0)
{ {
error_printf_silent("Failed to read from socket: %s", strerror(errno)); error_printf_silent("Failed to read from socket (%s)", strerror(errno));
close(clientfds[i]); close(clientfds[i]);
clientfds[i] = -1; clientfds[i] = -1;
continue; continue;

View file

@ -135,7 +135,7 @@ static void toggle_line(const char *line_name, int mask)
if (ioctl(fd, TIOCMGET, &state) < 0) if (ioctl(fd, TIOCMGET, &state) < 0)
{ {
warning_printf("Could not get line state: %s", strerror(errno)); warning_printf("Could not get line state (%s)", strerror(errno));
} }
else else
{ {
@ -150,7 +150,7 @@ static void toggle_line(const char *line_name, int mask)
tio_printf("set %s to HIGH", line_name); tio_printf("set %s to HIGH", line_name);
} }
if (ioctl(fd, TIOCMSET, &state) < 0) if (ioctl(fd, TIOCMSET, &state) < 0)
warning_printf("Could not set line state: %s", strerror(errno)); warning_printf("Could not set line state (%s)", strerror(errno));
} }
} }
@ -196,7 +196,7 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c
case KEY_SHIFT_L: case KEY_SHIFT_L:
if (ioctl(fd, TIOCMGET, &state) < 0) if (ioctl(fd, TIOCMGET, &state) < 0)
{ {
warning_printf("Could not get line state: %s", strerror(errno)); warning_printf("Could not get line state (%s)", strerror(errno));
break; break;
} }
tio_printf("Line states:"); tio_printf("Line states:");