From c57844b08bced71778f38f2346464c3e0836287c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 1 Nov 2019 22:06:40 +0100 Subject: Add some functions and add functions with _failed suffix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- shutdown.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'shutdown.c') diff --git a/shutdown.c b/shutdown.c index ca6049b..7ea4103 100644 --- a/shutdown.c +++ b/shutdown.c @@ -2,33 +2,43 @@ #include "internal.h" -int -liberror_shutdown(int fd, int how, const char *fname) +void +liberror_shutdown_failed(int fd, int how, const char *fname) { const char *desc; - if (!shutdown(fd, how)) - return 0; switch (errno) { case EBADF: - desc = fd < 0 ? "Negative file descriptor number specified" : "Unassigned file descriptor number specified"; + if (fd < 0) + desc = "Negative file descriptor number specified"; + else + desc = "Unassigned file descriptor number specified"; break; case EINVAL: desc = "Invalid value of second parameter"; break; + case ENOBUFS: + desc = "Insufficient resource available in the system to perform the operation"; + break; case ENOTCONN: desc = "The socket is not connected"; break; case ENOTSOCK: - desc = "The specified file is not a socket"; - break; - case ENOBUFS: - desc = "Insufficient resource available in the system to perform the operation"; + desc = "The file descriptor refer to a non-socket file"; break; default: desc = ""; break; } - liberror_save_backtrace(NULL); liberror_libc_set_error_one_file(desc, "shutdown", "Socket file", fd, fname); +} + + +int +liberror_shutdown(int fd, int how, const char *fname) +{ + if (!shutdown(fd, how)) + return 0; + liberror_save_backtrace(NULL); + liberror_shutdown_failed(fd, how, fname); return -1; } -- cgit v1.2.3-70-g09d2