Make rk_SOCK_INIT an inline function and check the result to avoid warnings

Similar to f6e0d19cc0 but
fixed in the header by making it a proper static inline
function (as some callers treats it as one, so do it
for all now for consistency).

Seen on Ubuntu 18.04 with

giving:

In file included from getaddrinfo-test.c:36:0:
getaddrinfo-test.c: In function ‘main’:
roken.h:110:24: error: statement with no effect [-Werror=unused-value]
 #define rk_SOCK_INIT() 0
                        ^
getaddrinfo-test.c:132:5: note: in expansion of macro ‘rk_SOCK_INIT’
     rk_SOCK_INIT();
     ^~~~~~~~~~~~

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andrew Bartlett
2020-05-28 20:09:43 +12:00
committed by Jeffrey Altman
parent 9ffbc17a0f
commit bf3c4219fe
3 changed files with 10 additions and 4 deletions

View File

@@ -129,7 +129,8 @@ main(int argc, char **argv)
return 0;
}
rk_SOCK_INIT();
if (rk_SOCK_INIT())
errx(1, "Couldn't initialize sockets. Err=%d\n", rk_SOCK_ERRNO);
argc -= optidx;
argv += optidx;

View File

@@ -132,7 +132,10 @@ typedef int rk_socket_t;
#define rk_SOCK_ERRNO errno
#define rk_INVALID_SOCKET (-1)
#define rk_SOCK_INIT() 0
static inline ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL rk_SOCK_INIT(void) {
return 0;
}
#define rk_SOCK_EXIT() do { } while(0)
#endif /* WinSock */

View File

@@ -253,7 +253,8 @@ do_client(void)
{
int rv = 0;
rk_SOCK_INIT();
if (rk_SOCK_INIT())
errx(1, "Couldn't initialize sockets. Err=%d\n", rk_SOCK_ERRNO);
prog = "Client";
is_client = 1;
@@ -272,7 +273,8 @@ do_server(void)
{
int rv = 0;
rk_SOCK_INIT();
if (rk_SOCK_INIT())
errx(1, "Couldn't initialize sockets. Err=%d\n", rk_SOCK_ERRNO);
prog = "Server";