Skip to content

Commit

Permalink
Cast lua value to int before passing to C function
Browse files Browse the repository at this point in the history
  • Loading branch information
tkan145 committed Feb 19, 2024
1 parent 4bc1d75 commit 2bf78fb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lfs_ffi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2bf78fb

Please sign in to comment.