From 472cd783d7a98f6dfe549ac0d59f3fe8f2ea59c8 Mon Sep 17 00:00:00 2001 From: rpatters1 Date: Tue, 12 Dec 2023 17:05:42 -0600 Subject: Fix a few compiler warnings (#171) Fixes warnings (probably) introduced with 64-bit. Mainly explicit typecasts to int to silence "possible loss of precision" warnings. These are lengths of filenames, so they're not going to exceed 4GB. --- src/lfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lfs.c b/src/lfs.c index e5e5ee4..f0a0db9 100644 --- a/src/lfs.c +++ b/src/lfs.c @@ -281,7 +281,7 @@ static int get_dir(lua_State * L) break; } path = path2; - if (getcwd(path, size) != NULL) { + if (getcwd(path, (int)size) != NULL) { /* success, push the path to the Lua stack */ lua_pushstring(L, path); result = 1; @@ -1062,7 +1062,7 @@ static int push_link_target(lua_State * L) } #endif char *target = NULL; - int tsize, size = 256; /* size = initial buffer capacity */ + int tsize = 0, size = 256; /* size = initial buffer capacity */ int ok = 0; while (!ok) { char *target2 = realloc(target, size); @@ -1071,9 +1071,9 @@ static int push_link_target(lua_State * L) } target = target2; #ifdef _WIN32 - tsize = GetFinalPathNameByHandle(h, target, size, FILE_NAME_OPENED); + tsize = (int)GetFinalPathNameByHandle(h, target, size, FILE_NAME_OPENED); #else - tsize = readlink(file, target, size); + tsize = (int)readlink(file, target, size); #endif if (tsize < 0) { /* a readlink() error occurred */ break; -- cgit v1.2.3-55-g6feb