From 83a7665a0e5e1b2bee53d7331f012cdfa323f191 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 1 Dec 2019 20:25:20 +0100 Subject: util.*.c: Add static qualifiers everywhere --- util-src/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util-src/net.c') diff --git a/util-src/net.c b/util-src/net.c index 5f706d81..d9c6b914 100644 --- a/util-src/net.c +++ b/util-src/net.c @@ -36,7 +36,7 @@ /* Enumerate all locally configured IP addresses */ -const char *const type_strings[] = { +static const char *const type_strings[] = { "both", "ipv4", "ipv6", -- cgit v1.2.3 From 61789d01d9b260ee0201fe27f6fb71fc7507971e Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 30 Jan 2020 14:22:21 +0100 Subject: util.net: Fix signedness warning on ARM net.c:87:56: warning: comparison of integer expressions of different signedness: ?long unsigned int? and ?long int? [-Wsign-compare] --- util-src/net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util-src/net.c') diff --git a/util-src/net.c b/util-src/net.c index d9c6b914..c3b07815 100644 --- a/util-src/net.c +++ b/util-src/net.c @@ -46,8 +46,8 @@ static const char *const type_strings[] = { static int lc_local_addresses(lua_State *L) { #ifndef _WIN32 /* Link-local IPv4 addresses; see RFC 3927 and RFC 5735 */ - const long ip4_linklocal = htonl(0xa9fe0000); /* 169.254.0.0 */ - const long ip4_mask = htonl(0xffff0000); + const uint32_t ip4_linklocal = htonl(0xa9fe0000); /* 169.254.0.0 */ + const uint32_t ip4_mask = htonl(0xffff0000); struct ifaddrs *addr = NULL, *a; #endif int n = 1; -- cgit v1.2.3 From c7f339117d74a9a57268c44d0b20354e674df0c5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 7 Jun 2020 02:25:56 +0200 Subject: util-src: Use the luaL_pushfail API added in Lua 5.4 to highlight all failure conditions Actually just an alias of pushnil, but it does make it more obvious where the failure conditions are, which is good for readability. --- util-src/net.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'util-src/net.c') diff --git a/util-src/net.c b/util-src/net.c index c3b07815..d786e885 100644 --- a/util-src/net.c +++ b/util-src/net.c @@ -33,6 +33,9 @@ #if (LUA_VERSION_NUM == 501) #define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R) #endif +#if (LUA_VERSION_NUM < 504) +#define luaL_pushfail lua_pushnil +#endif /* Enumerate all locally configured IP addresses */ @@ -59,7 +62,7 @@ static int lc_local_addresses(lua_State *L) { #ifndef _WIN32 if(getifaddrs(&addr) < 0) { - lua_pushnil(L); + luaL_pushfail(L); lua_pushfstring(L, "getifaddrs failed (%d): %s", errno, strerror(errno)); return 2; @@ -141,14 +144,14 @@ static int lc_pton(lua_State *L) { case -1: errno_ = errno; - lua_pushnil(L); + luaL_pushfail(L); lua_pushstring(L, strerror(errno_)); lua_pushinteger(L, errno_); return 3; default: case 0: - lua_pushnil(L); + luaL_pushfail(L); lua_pushstring(L, strerror(EINVAL)); lua_pushinteger(L, EINVAL); return 3; @@ -170,7 +173,7 @@ static int lc_ntop(lua_State *L) { family = AF_INET; } else { - lua_pushnil(L); + luaL_pushfail(L); lua_pushstring(L, strerror(EAFNOSUPPORT)); lua_pushinteger(L, EAFNOSUPPORT); return 3; @@ -179,7 +182,7 @@ static int lc_ntop(lua_State *L) { if(!inet_ntop(family, ipaddr, buf, INET6_ADDRSTRLEN)) { errno_ = errno; - lua_pushnil(L); + luaL_pushfail(L); lua_pushstring(L, strerror(errno_)); lua_pushinteger(L, errno_); return 3; -- cgit v1.2.3