Skip to content

Commit

Permalink
Fix a few compiler warnings (#171)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rpatters1 committed Dec 12, 2023
1 parent 912e067 commit 472cd78
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 472cd78

Please sign in to comment.