From 4159a1436462c8aaea889a9f7c3664fd00686b43 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 5 Dec 2017 04:47:59 +0100 Subject: [PATCH] afd: make afd_get_protocol() error reporting more accurate --- src/afd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/afd.c b/src/afd.c index 2c071bd..79eb1a0 100644 --- a/src/afd.c +++ b/src/afd.c @@ -150,19 +150,18 @@ WEPOLL_INTERNAL ssize_t afd_get_protocol(SOCKET socket, if (id < 0) { /* If getting protocol information failed, it might be due to the socket * not being an AFD socket. If so, attempt to fetch the underlying base - * socket, then try again to obtain protocol information. If that also - * fails, return the *original* error. */ - DWORD original_error = GetLastError(); - if (original_error != ERROR_NOT_SUPPORTED) - return_error(-1); + * socket, then try again to obtain protocol information. */ + DWORD error = GetLastError(); + if (error != ERROR_NOT_SUPPORTED) + return -1; afd_socket = _afd_get_base_socket(socket); if (afd_socket == INVALID_SOCKET || afd_socket == socket) - return_error(-1, original_error); + return_error(-1, error); id = _afd_get_protocol_info(afd_socket, protocol_info); if (id < 0) - return_error(-1, original_error); + return -1; } *afd_socket_out = afd_socket;