Logging cleanups

- Consistently use %m instead of strerror(errno)
- Add some missing \n's
This commit is contained in:
Kim Woelders
2018-10-11 14:53:51 +02:00
parent 44ddf67386
commit e8913f62af
+12 -13
View File
@@ -211,7 +211,7 @@ static void *_read_net(void *arg)
NET_BUF_SIZE - tty->net_cnt);
if (res < 0)
{
_log(LOG_ERR, "net read error: %s\n", strerror(errno));
_log(LOG_ERR, "net read error: %m\n");
break;
}
if (res == 0)
@@ -227,7 +227,7 @@ static void *_read_net(void *arg)
write(tty->fds[FD_MASTER].fd, tty->net_buf, tty->net_cnt);
if (res < 0)
{
_log(LOG_ERR, "master write error:%s\n", strerror(errno));
_log(LOG_ERR, "master write error: %m\n");
break;
}
tty->net_cnt = 0;
@@ -239,7 +239,7 @@ static void *_read_net(void *arg)
res = read(tty->fds[FD_MASTER].fd, tty->tmp_buf, TMP_BUF_SIZE);
if (res < 0)
{
_log(LOG_ERR, "master read error:%s\n", strerror(errno));
_log(LOG_ERR, "master read error: %m\n");
break;
}
telnet_tx(tty->tn, tty->tmp_buf, res);
@@ -267,14 +267,14 @@ static int _srv_connect(const char *host, unsigned int port)
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
_log(LOG_ERR, "Socket open failed: %s\n", strerror(errno));
_log(LOG_ERR, "Socket open failed: %m\n");
return sockfd;
}
server = gethostbyname(host);
if (server == NULL)
{
_log(LOG_ERR, "Cannot resolve host name: %s\n", strerror(errno));
_log(LOG_ERR, "Cannot resolve host name: %m\n");
close(sockfd);
return -1;
}
@@ -288,8 +288,7 @@ static int _srv_connect(const char *host, unsigned int port)
err = connect(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
if (err < 0)
{
_log(LOG_ERR, "Failed to connect to: %s:%u:%s\n",
host, port, strerror(errno));
_log(LOG_ERR, "Failed to connect to: %s:%u: %m\n", host, port);
close(sockfd);
return -1;
}
@@ -457,8 +456,8 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
open_err:
_log(LOG_INFO, "Connection to server: %s:%d failed:%s\n",
ttynvt_param.host, ttynvt_param.port, strerror(errno));
_log(LOG_INFO, "Connection to server: %s:%d failed: %m\n",
ttynvt_param.host, ttynvt_param.port);
for (n = 0; n < 3; n++)
if (tty->fds[n].fd >= 0)
@@ -501,7 +500,7 @@ ttynvt_read(fuse_req_t req, size_t size, off_t off,
fuse_req_interrupt_func(req, NULL, NULL);
if (res < 0)
{
DBG2("read (slave) error: %s\n", strerror(errno));
DBG2("read (slave) error: %m\n");
fuse_reply_err(req, errno);
return;
}
@@ -534,7 +533,7 @@ ttynvt_write(fuse_req_t req, const char *data, size_t size, off_t off,
res = write(tty->fds[FD_SLAVE].fd, data, size);
if (res < 0)
{
DBG2("write (slave) error: %s\n", strerror(errno));
DBG2("write (slave) error: %m\n");
tty->error = 1;
fuse_reply_err(req, errno);
return;
@@ -1020,14 +1019,14 @@ int main(int argc, char *argv[])
switch (cpid)
{
case -1:
_log(LOG_ERR, "fork(): %m");
_log(LOG_ERR, "fork(): %m\n");
return -1;
case 0: /* Child */
DBG("Child proceeding...\n");
rc = cuse_lowlevel_main(args.argc, args.argv, &ci, &ttynvt_op, NULL);
if (rc != 0)
_log(LOG_ERR, "ttynvt failed rc=%d", rc);
_log(LOG_ERR, "ttynvt failed rc=%d\n", rc);
else
DBG("Child exited\n");
return rc;