From 2bf78fb9438f521966a478416ed82b5575107f4b Mon Sep 17 00:00:00 2001 From: An Tran Date: Fri, 16 Feb 2024 18:33:09 +1000 Subject: [PATCH] Cast lua value to int before passing to C function --- lfs_ffi.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lfs_ffi.lua b/lfs_ffi.lua index 48b3f39..ec5ed89 100644 --- a/lfs_ffi.lua +++ b/lfs_ffi.lua @@ -20,6 +20,7 @@ local _M = { -- common utils/constants local IS_64_BIT = ffi.abi('64bit') local ERANGE = 'Result too large' +local int = ffi.typeof("int") ffi.cdef([[ char* strerror(int errnum); @@ -945,10 +946,10 @@ if OS == 'Linux' then -- On arm64 stat and lstat do not exist as syscall, so use newfstatat instead -- int newfstatat(int dirfd, const char *filename, struct stat *statbuf, int flags) stat_func = function(filepath, buf) - return lib.syscall(79, STAT._AT_FDCWD, filepath, buf, 0) + return lib.syscall(79, int(STAT._AT_FDCWD), filepath, buf, 0) end lstat_func = function(filepath, buf) - return lib.syscall(79, STAT._AT_FDCWD, filepath, buf, STAT._AT_SYMLINK_NOFOLLOW) + return lib.syscall(79, int(STAT._AT_FDCWD), filepath, buf, int(STAT._AT_SYMLINK_NOFOLLOW)) end elseif stat_syscall_num then