Misc Fixes

This commit is contained in:
David PHAM-VAN 2017-03-17 14:05:21 -07:00
parent d6f78df195
commit 5a66fe841a
5 changed files with 15 additions and 12 deletions

View File

@ -578,7 +578,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (file->file_handle == INVALID_HANDLE_VALUE)
{
WLog_ERR(TAG, "Unable to set file time %s (%d)", file->fullpath, GetLastError());
WLog_ERR(TAG, "Unable to set file time %s (%"PRId32")", file->fullpath, GetLastError());
return FALSE;
}
@ -614,7 +614,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (!SetFileTime(file->file_handle, pftCreationTime, pftLastAccessTime, pftLastWriteTime))
{
WLog_ERR(TAG, "Unable to set file time %s to %d", file->fullpath);
WLog_ERR(TAG, "Unable to set file time to %s", file->fullpath);
return FALSE;
}
@ -630,7 +630,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (file->file_handle == INVALID_HANDLE_VALUE)
{
WLog_ERR(TAG, "Unable to truncate %s to %"PRId64" (%d)", file->fullpath, size, GetLastError());
WLog_ERR(TAG, "Unable to truncate %s to %"PRId64" (%"PRId32")", file->fullpath, size, GetLastError());
return FALSE;
}
@ -639,7 +639,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (SetFilePointer(file->file_handle, liSize.LowPart, &liSize.HighPart,
FILE_BEGIN) == INVALID_SET_FILE_POINTER)
{
WLog_ERR(TAG, "Unable to truncate %s to %d (%d)", file->fullpath, size, GetLastError());
WLog_ERR(TAG, "Unable to truncate %s to %d (%"PRId32")", file->fullpath, size, GetLastError());
return FALSE;
}
@ -647,7 +647,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
if (SetEndOfFile(file->file_handle) == 0)
{
WLog_ERR(TAG, "Unable to truncate %s to %d (%d)", file->fullpath, size, GetLastError());
WLog_ERR(TAG, "Unable to truncate %s to %d (%"PRId32")", file->fullpath, size, GetLastError());
return FALSE;
}

View File

@ -124,7 +124,7 @@ static DWORD drive_map_windows_err(DWORD fs_errno)
default:
rc = STATUS_UNSUCCESSFUL;
WLog_ERR(TAG, "Error code not found: %d", fs_errno);
WLog_ERR(TAG, "Error code not found: %"PRId32"", fs_errno);
break;
}

View File

@ -136,6 +136,9 @@ WCHAR* _wcsrchr(const WCHAR* str, WCHAR c)
WCHAR *p;
WCHAR ch;
if (!str)
return NULL;
for (p = (WCHAR *) 0; (ch = *str); str++)
if (ch == c)
p = (WCHAR *) str;

View File

@ -105,7 +105,7 @@ static BOOL FileSetEndOfFile(HANDLE hFile)
return FALSE;
size = ftell(pFile->fp);
errno = 0;
if (ftruncate(fileno(pFile->fp), size) < 0)
{
WLog_ERR(TAG, "ftruncate %s failed with %s [0x%08X]",
@ -171,10 +171,10 @@ static BOOL FileRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
return FALSE;
file = (WINPR_FILE *)Object;
errno = 0;
clearerr(file->fp);
io_status = fread(lpBuffer, 1, nNumberOfBytesToRead, file->fp);
if (io_status == 0 && errno != 0)
if (io_status == 0 && ferror(file->fp))
{
status = FALSE;
@ -212,9 +212,9 @@ static BOOL FileWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrit
file = (WINPR_FILE *)Object;
errno = 0;
clearerr(file->fp);
io_status = fwrite(lpBuffer, 1, nNumberOfBytesToWrite, file->fp);
if (io_status == 0 && errno != 0)
if (io_status == 0 && ferror(file->fp))
{
SetLastError(map_posix_err(errno));
return FALSE;

View File

@ -525,7 +525,7 @@ BOOL PathIsDirectoryEmptyA(LPCSTR pszPath)
int empty = 1;
DIR *dir = opendir(pszPath);
if (dir == NULL) //Not a directory or doesn't exist
if (dir == NULL) /* Not a directory or doesn't exist */
return 1;
while ((dp = readdir(dir)) != NULL) {