Logging cleanups
- Consistently use %m instead of strerror(errno) - Add some missing \n's
This commit is contained in:
@@ -211,7 +211,7 @@ static void *_read_net(void *arg)
|
|||||||
NET_BUF_SIZE - tty->net_cnt);
|
NET_BUF_SIZE - tty->net_cnt);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
_log(LOG_ERR, "net read error: %s\n", strerror(errno));
|
_log(LOG_ERR, "net read error: %m\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (res == 0)
|
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);
|
write(tty->fds[FD_MASTER].fd, tty->net_buf, tty->net_cnt);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
_log(LOG_ERR, "master write error:%s\n", strerror(errno));
|
_log(LOG_ERR, "master write error: %m\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tty->net_cnt = 0;
|
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);
|
res = read(tty->fds[FD_MASTER].fd, tty->tmp_buf, TMP_BUF_SIZE);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
_log(LOG_ERR, "master read error:%s\n", strerror(errno));
|
_log(LOG_ERR, "master read error: %m\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
telnet_tx(tty->tn, tty->tmp_buf, res);
|
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);
|
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (sockfd < 0)
|
if (sockfd < 0)
|
||||||
{
|
{
|
||||||
_log(LOG_ERR, "Socket open failed: %s\n", strerror(errno));
|
_log(LOG_ERR, "Socket open failed: %m\n");
|
||||||
return sockfd;
|
return sockfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
server = gethostbyname(host);
|
server = gethostbyname(host);
|
||||||
if (server == NULL)
|
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);
|
close(sockfd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -288,8 +288,7 @@ static int _srv_connect(const char *host, unsigned int port)
|
|||||||
err = connect(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
|
err = connect(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
_log(LOG_ERR, "Failed to connect to: %s:%u:%s\n",
|
_log(LOG_ERR, "Failed to connect to: %s:%u: %m\n", host, port);
|
||||||
host, port, strerror(errno));
|
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -457,8 +456,8 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
|
|||||||
|
|
||||||
open_err:
|
open_err:
|
||||||
|
|
||||||
_log(LOG_INFO, "Connection to server: %s:%d failed:%s\n",
|
_log(LOG_INFO, "Connection to server: %s:%d failed: %m\n",
|
||||||
ttynvt_param.host, ttynvt_param.port, strerror(errno));
|
ttynvt_param.host, ttynvt_param.port);
|
||||||
|
|
||||||
for (n = 0; n < 3; n++)
|
for (n = 0; n < 3; n++)
|
||||||
if (tty->fds[n].fd >= 0)
|
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);
|
fuse_req_interrupt_func(req, NULL, NULL);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
DBG2("read (slave) error: %s\n", strerror(errno));
|
DBG2("read (slave) error: %m\n");
|
||||||
fuse_reply_err(req, errno);
|
fuse_reply_err(req, errno);
|
||||||
return;
|
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);
|
res = write(tty->fds[FD_SLAVE].fd, data, size);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
DBG2("write (slave) error: %s\n", strerror(errno));
|
DBG2("write (slave) error: %m\n");
|
||||||
tty->error = 1;
|
tty->error = 1;
|
||||||
fuse_reply_err(req, errno);
|
fuse_reply_err(req, errno);
|
||||||
return;
|
return;
|
||||||
@@ -1020,14 +1019,14 @@ int main(int argc, char *argv[])
|
|||||||
switch (cpid)
|
switch (cpid)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
_log(LOG_ERR, "fork(): %m");
|
_log(LOG_ERR, "fork(): %m\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case 0: /* Child */
|
case 0: /* Child */
|
||||||
DBG("Child proceeding...\n");
|
DBG("Child proceeding...\n");
|
||||||
rc = cuse_lowlevel_main(args.argc, args.argv, &ci, &ttynvt_op, NULL);
|
rc = cuse_lowlevel_main(args.argc, args.argv, &ci, &ttynvt_op, NULL);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
_log(LOG_ERR, "ttynvt failed rc=%d", rc);
|
_log(LOG_ERR, "ttynvt failed rc=%d\n", rc);
|
||||||
else
|
else
|
||||||
DBG("Child exited\n");
|
DBG("Child exited\n");
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
Reference in New Issue
Block a user