diff --git a/src/host/buffered_io.c b/src/host/buffered_io.c index 160bbccf..018402be 100644 --- a/src/host/buffered_io.c +++ b/src/host/buffered_io.c @@ -16,7 +16,7 @@ void buffer_init(Buffer* b) b->data = NULL; } -void buffer_destroy(Buffer* b) +void buffer_destroy(Buffer* b) { free(b->data); b->capacity = 0; @@ -53,12 +53,13 @@ void buffer_puts(Buffer* b, const void* ptr, size_t len) b->length += len; } -void buffer_printf(Buffer* b, const char *fmt, ...) +void buffer_printf(Buffer* b, const char *fmt, ...) { char text[2048]; + int len; va_list args; va_start(args, fmt); - int len = vsnprintf(text, sizeof(text) - 1, fmt, args); + len = vsnprintf(text, sizeof(text) - 1, fmt, args); va_end(args); buffer_puts(b, text, len); } diff --git a/src/host/os_chdir.c b/src/host/os_chdir.c index 28aa0fcd..b51292af 100644 --- a/src/host/os_chdir.c +++ b/src/host/os_chdir.c @@ -11,8 +11,6 @@ int do_chdir(lua_State* L, const char* path) { int z; - (void)(L); /* warning: unused parameter */ - #if PLATFORM_WINDOWS wchar_t wide_buffer[PATH_MAX]; if (MultiByteToWideChar(CP_UTF8, 0, path, -1, wide_buffer, PATH_MAX) == 0) @@ -23,6 +21,8 @@ int do_chdir(lua_State* L, const char* path) z = SetCurrentDirectoryW(wide_buffer); #else + (void)(L); /* warning: unused parameter */ + z = !chdir(path); #endif diff --git a/src/host/os_getversion.c b/src/host/os_getversion.c index 970ff237..40b0c83c 100644 --- a/src/host/os_getversion.c +++ b/src/host/os_getversion.c @@ -67,7 +67,7 @@ int getKernelVersion(struct OsVersionInfo* info) { void* fixedInfoPtr; UINT fixedInfoSize; - if (VerQueryValueA(data, "\\", &fixedInfoPtr, &fixedInfoSize)) + if (VerQueryValueA(data, "\\", &fixedInfoPtr, &fixedInfoSize)) { VS_FIXEDFILEINFO* fileInfo = (VS_FIXEDFILEINFO*)fixedInfoPtr; info->majorversion = HIWORD(fileInfo->dwProductVersionMS); @@ -82,10 +82,10 @@ int getKernelVersion(struct OsVersionInfo* info) int getversion(struct OsVersionInfo* info) { + HKEY key; info->description = "Windows"; // First get a friendly product name from the registry. - HKEY key; if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &key) == ERROR_SUCCESS) { char value[512]; diff --git a/src/host/os_isfile.c b/src/host/os_isfile.c index 2bad6f04..c2a10768 100644 --- a/src/host/os_isfile.c +++ b/src/host/os_isfile.c @@ -18,10 +18,9 @@ int os_isfile(lua_State* L) int do_isfile(lua_State* L, const char* filename) { - (void)(L); /* warning: unused parameter */ - #if PLATFORM_WINDOWS wchar_t wide_path[PATH_MAX]; + DWORD attrib; if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, wide_path, PATH_MAX) == 0) { @@ -29,13 +28,16 @@ int do_isfile(lua_State* L, const char* filename) return lua_error(L); } - DWORD attrib = GetFileAttributesW(wide_path); + attrib = GetFileAttributesW(wide_path); if (attrib != INVALID_FILE_ATTRIBUTES) { return (attrib & FILE_ATTRIBUTE_DIRECTORY) == 0; } #else struct stat buf; + + (void)(L); /* warning: unused parameter */ + if (stat(filename, &buf) == 0) { return ((buf.st_mode & S_IFDIR) == 0); diff --git a/src/host/os_islink.c b/src/host/os_islink.c index 1c2dee91..4ce0902d 100644 --- a/src/host/os_islink.c +++ b/src/host/os_islink.c @@ -15,13 +15,14 @@ int os_islink(lua_State* L) #if PLATFORM_WINDOWS { wchar_t wide_path[PATH_MAX]; + DWORD attr; if (MultiByteToWideChar(CP_UTF8, 0, path, -1, wide_path, PATH_MAX) == 0) { lua_pushstring(L, "unable to encode path"); return lua_error(L); } - DWORD attr = GetFileAttributesW(wide_path); + attr = GetFileAttributesW(wide_path); if (attr != INVALID_FILE_ATTRIBUTES) { lua_pushboolean(L, (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0); return 1; diff --git a/src/host/os_match.c b/src/host/os_match.c index 2a25df68..a60e64d7 100644 --- a/src/host/os_match.c +++ b/src/host/os_match.c @@ -21,6 +21,7 @@ typedef struct struct_MatchInfo int os_matchstart(lua_State* L) { const char* mask = luaL_checkstring(L, 1); + MatchInfo* m; wchar_t wide_mask[PATH_MAX]; if (MultiByteToWideChar(CP_UTF8, 0, mask, -1, wide_mask, PATH_MAX) == 0) @@ -29,7 +30,7 @@ int os_matchstart(lua_State* L) return lua_error(L); } - MatchInfo* m = (MatchInfo*)malloc(sizeof(MatchInfo)); + m = (MatchInfo*)malloc(sizeof(MatchInfo)); m->handle = FindFirstFileW(wide_mask, &m->entry); m->is_first = 1;