libs/nixio: fix uninitialized variable warning on Darwin in splice.c
[project/luci.git] / libs / nixio / src / splice.c
index fe56661..db63ea9 100644 (file)
@@ -90,7 +90,7 @@ static int nixio_splice(lua_State *L) {
                return nixio__perror(L);
        }
 
-       lua_pushnumber(L, spliced);
+       lua_pushinteger(L, spliced);
        return 1;
 }
 
@@ -143,7 +143,12 @@ static int nixio_sendfile(lua_State *L) {
        const off_t offset = lseek(infd, 0, SEEK_CUR);
 
        do {
+#ifdef __DARWIN__
+               r = sendfile(infd, sock, offset, (off_t *)&len, NULL, 0);
+               spliced = r;
+#else
                r = sendfile(infd, sock, offset, len, NULL, &spliced, 0);
+#endif
        } while (r == -1 && errno == EINTR);
 
        if (r == -1) {
@@ -151,7 +156,7 @@ static int nixio_sendfile(lua_State *L) {
        }
 #endif
 
-       lua_pushnumber(L, spliced);
+       lua_pushinteger(L, spliced);
        return 1;
 }