mirror of
https://github.com/OpenVPN/openvpn.git
synced 2024-11-27 11:43:51 +08:00
use M_ERRNO instead of explicitly printing errno
the msg() function will print the errno for us when provided with the M_ERRNO flag. Therefore, don't bother printing errno explicitly and always pass M_ERRNO to msg(). Signed-off-by: Antonio Quartulli <antonio@openvpn.net> Acked-by: Arne Schwabe <arne@rfc2549.org> Message-Id: <20170713080527.13299-1-a@unstable.cc> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15056.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
parent
f9ebfe1b5a
commit
56b396dcbc
@ -1878,17 +1878,15 @@ man_connect(struct management *man)
|
||||
#if UNIX_SOCK_SUPPORT
|
||||
if (man->settings.flags & MF_UNIX_SOCK)
|
||||
{
|
||||
msg(D_LINK_ERRORS,
|
||||
"MANAGEMENT: connect to unix socket %s failed: %s",
|
||||
sockaddr_unix_name(&man->settings.local_unix, "NULL"),
|
||||
strerror_ts(status, &gc));
|
||||
msg(D_LINK_ERRORS | M_ERRNO,
|
||||
"MANAGEMENT: connect to unix socket %s failed",
|
||||
sockaddr_unix_name(&man->settings.local_unix, "NULL"));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
msg(D_LINK_ERRORS,
|
||||
"MANAGEMENT: connect to %s failed: %s",
|
||||
print_sockaddr(man->settings.local->ai_addr, &gc),
|
||||
strerror_ts(status, &gc));
|
||||
msg(D_LINK_ERRORS | M_ERRNO,
|
||||
"MANAGEMENT: connect to %s failed",
|
||||
print_sockaddr(man->settings.local->ai_addr, &gc));
|
||||
throw_signal_soft(SIGTERM, "management-connect-failed");
|
||||
goto done;
|
||||
}
|
||||
|
@ -928,10 +928,8 @@ create_temp_file(const char *directory, const char *prefix, struct gc_arena *gc)
|
||||
else if (fd == -1 && errno != EEXIST)
|
||||
{
|
||||
/* Something else went wrong, no need to retry. */
|
||||
struct gc_arena gcerr = gc_new();
|
||||
msg(M_FATAL, "Could not create temporary file '%s': %s",
|
||||
retfname, strerror_ts(errno, &gcerr));
|
||||
gc_free(&gcerr);
|
||||
msg(M_FATAL | M_ERRNO, "Could not create temporary file '%s'",
|
||||
retfname);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -797,7 +797,7 @@ tunnel_server_tcp(struct context *top)
|
||||
multi.top.c2.inotify_fd = inotify_init();
|
||||
if (multi.top.c2.inotify_fd < 0)
|
||||
{
|
||||
msg(D_MULTI_ERRORS, "MULTI: inotify_init error: %s", strerror(errno));
|
||||
msg(D_MULTI_ERRORS | M_ERRNO, "MULTI: inotify_init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -325,7 +325,7 @@ tunnel_server_udp_single_threaded(struct context *top)
|
||||
multi.top.c2.inotify_fd = inotify_init();
|
||||
if (multi.top.c2.inotify_fd < 0)
|
||||
{
|
||||
msg(D_MULTI_ERRORS, "MULTI: inotify_init error: %s", strerror(errno));
|
||||
msg(D_MULTI_ERRORS | M_ERRNO, "MULTI: inotify_init error");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2355,7 +2355,7 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const uns
|
||||
}
|
||||
else
|
||||
{
|
||||
msg(M_NONFATAL, "MULTI: inotify_add_watch error: %s", strerror(errno));
|
||||
msg(M_NONFATAL | M_ERRNO, "MULTI: inotify_add_watch error");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3137,8 +3137,7 @@ check_file_access(const int type, const char *file, const int mode, const char *
|
||||
/* Scream if an error is found */
|
||||
if (errcode > 0)
|
||||
{
|
||||
msg(M_NOPREFIX|M_OPTERR, "%s fails with '%s': %s",
|
||||
opt, file, strerror(errno));
|
||||
msg(M_NOPREFIX | M_OPTERR | M_ERRNO, "%s fails with '%s'", opt, file);
|
||||
}
|
||||
|
||||
/* Return true if an error occured */
|
||||
|
@ -1297,11 +1297,9 @@ socket_bind(socket_descriptor_t sd,
|
||||
}
|
||||
if (bind(sd, cur->ai_addr, cur->ai_addrlen))
|
||||
{
|
||||
const int errnum = openvpn_errno();
|
||||
msg(M_FATAL, "%s: Socket bind failed on local address %s: %s",
|
||||
msg(M_FATAL | M_ERRNO, "%s: Socket bind failed on local address %s",
|
||||
prefix,
|
||||
print_sockaddr_ex(local->ai_addr, ":", PS_SHOW_PORT, &gc),
|
||||
strerror_ts(errnum, &gc));
|
||||
print_sockaddr_ex(local->ai_addr, ":", PS_SHOW_PORT, &gc));
|
||||
}
|
||||
gc_free(&gc);
|
||||
}
|
||||
@ -3888,12 +3886,11 @@ socket_bind_unix(socket_descriptor_t sd,
|
||||
|
||||
if (bind(sd, (struct sockaddr *) local, sizeof(struct sockaddr_un)))
|
||||
{
|
||||
const int errnum = openvpn_errno();
|
||||
msg(M_FATAL, "%s: Socket bind[%d] failed on unix domain socket %s: %s",
|
||||
msg(M_FATAL | M_ERRNO,
|
||||
"%s: Socket bind[%d] failed on unix domain socket %s",
|
||||
prefix,
|
||||
(int)sd,
|
||||
sockaddr_unix_name(local, "NULL"),
|
||||
strerror_ts(errnum, &gc));
|
||||
sockaddr_unix_name(local, "NULL"));
|
||||
}
|
||||
|
||||
#ifdef HAVE_UMASK
|
||||
|
@ -178,7 +178,7 @@ status_flush(struct status_output *so)
|
||||
const off_t off = lseek(so->fd, (off_t)0, SEEK_CUR);
|
||||
if (ftruncate(so->fd, off) != 0)
|
||||
{
|
||||
msg(M_WARN, "Failed to truncate status file: %s", strerror(errno));
|
||||
msg(M_WARN | M_ERRNO, "Failed to truncate status file");
|
||||
}
|
||||
}
|
||||
#elif defined(HAVE_CHSIZE)
|
||||
|
@ -3022,16 +3022,14 @@ utun_open_helper(struct ctl_info ctlInfo, int utunnum)
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
msg(M_INFO, "Opening utun (%s): %s", "socket(SYSPROTO_CONTROL)",
|
||||
strerror(errno));
|
||||
msg(M_INFO | M_ERRNO, "Opening utun (socket(SYSPROTO_CONTROL))");
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (ioctl(fd, CTLIOCGINFO, &ctlInfo) == -1)
|
||||
{
|
||||
close(fd);
|
||||
msg(M_INFO, "Opening utun (%s): %s", "ioctl(CTLIOCGINFO)",
|
||||
strerror(errno));
|
||||
msg(M_INFO | M_ERRNO, "Opening utun (ioctl(CTLIOCGINFO))");
|
||||
return -2;
|
||||
}
|
||||
|
||||
@ -3049,8 +3047,7 @@ utun_open_helper(struct ctl_info ctlInfo, int utunnum)
|
||||
|
||||
if (connect(fd, (struct sockaddr *)&sc, sizeof(sc)) < 0)
|
||||
{
|
||||
msg(M_INFO, "Opening utun (%s): %s", "connect(AF_SYS_CONTROL)",
|
||||
strerror(errno));
|
||||
msg(M_INFO | M_ERRNO, "Opening utun (connect(AF_SYS_CONTROL))");
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user