[msvc] fix MSVC 64 bit conversion warnings

* use size_t in file.c
* remove obsolete Hungarian notation
This commit is contained in:
Pete Batard 2011-12-01 16:22:00 +00:00
parent af3607715a
commit 08d68301cd
3 changed files with 38 additions and 38 deletions

56
file.c
View File

@ -27,7 +27,7 @@ int write_sectors(HANDLE hDrive, size_t SectorSize,
const void *pBuf, size_t BufSize) const void *pBuf, size_t BufSize)
{ {
LARGE_INTEGER ptr; LARGE_INTEGER ptr;
DWORD dwSize; DWORD Size;
if(SectorSize * nSectors > BufSize) if(SectorSize * nSectors > BufSize)
{ {
@ -42,7 +42,7 @@ int write_sectors(HANDLE hDrive, size_t SectorSize,
return 0; return 0;
} }
if((!WriteFile(hDrive, pBuf, (DWORD)BufSize, &dwSize, NULL)) || (dwSize != BufSize)) if((!WriteFile(hDrive, pBuf, (DWORD)BufSize, &Size, NULL)) || (Size != BufSize))
{ {
uprintf("write_sectors: Write error - %s\n", WindowsErrorString()); uprintf("write_sectors: Write error - %s\n", WindowsErrorString());
return 0; return 0;
@ -56,7 +56,7 @@ int read_sectors(HANDLE hDrive, size_t SectorSize,
void *pBuf, size_t BufSize) void *pBuf, size_t BufSize)
{ {
LARGE_INTEGER ptr; LARGE_INTEGER ptr;
DWORD dwSize; DWORD Size;
if(SectorSize * nSectors > BufSize) if(SectorSize * nSectors > BufSize)
{ {
@ -71,7 +71,7 @@ int read_sectors(HANDLE hDrive, size_t SectorSize,
return 0; return 0;
} }
if((!ReadFile(hDrive, pBuf, (DWORD)BufSize, &dwSize, NULL)) || (dwSize != BufSize)) if((!ReadFile(hDrive, pBuf, (DWORD)BufSize, &Size, NULL)) || (Size != BufSize))
{ {
uprintf("read_sectors: Read error - %s\n", WindowsErrorString()); uprintf("read_sectors: Read error - %s\n", WindowsErrorString());
return 0; return 0;
@ -81,62 +81,62 @@ int read_sectors(HANDLE hDrive, size_t SectorSize,
} }
/* Use a bastardized fp that contains a Windows handle and the sector size */ /* Use a bastardized fp that contains a Windows handle and the sector size */
int contains_data(FILE *fp, unsigned long ulPosition, int contains_data(FILE *fp, size_t Position,
const void *pData, unsigned int uiLen) const void *pData, size_t Len)
{ {
unsigned char aucBuf[MAX_DATA_LEN]; unsigned char aucBuf[MAX_DATA_LEN];
HANDLE hDrive = (HANDLE)fp->_ptr; HANDLE hDrive = (HANDLE)fp->_ptr;
unsigned long ulSectorSize = (unsigned long)fp->_bufsiz; size_t SectorSize = (size_t)fp->_bufsiz;
unsigned long ulStartSector, ulEndSector, ulNumSectors; size_t StartSector, EndSector, NumSectors;
ulStartSector = ulPosition/ulSectorSize; StartSector = Position/SectorSize;
ulEndSector = (ulPosition+uiLen+ulSectorSize-1)/ulSectorSize; EndSector = (Position+Len+SectorSize-1)/SectorSize;
ulNumSectors = ulEndSector - ulStartSector; NumSectors = EndSector - StartSector;
if((ulNumSectors*ulSectorSize) > MAX_DATA_LEN) if((NumSectors*SectorSize) > MAX_DATA_LEN)
{ {
uprintf("Please increase MAX_DATA_LEN in file.h\n"); uprintf("Please increase MAX_DATA_LEN in file.h\n");
return 0; return 0;
} }
if(!read_sectors(hDrive, ulSectorSize, ulStartSector, if(!read_sectors(hDrive, SectorSize, StartSector,
ulNumSectors, aucBuf, sizeof(aucBuf))) NumSectors, aucBuf, sizeof(aucBuf)))
return 0; return 0;
if(memcmp(pData, &aucBuf[ulPosition - ulStartSector*ulSectorSize], uiLen)) if(memcmp(pData, &aucBuf[Position - StartSector*SectorSize], Len))
return 0; return 0;
return 1; return 1;
} /* contains_data */ } /* contains_data */
/* May read/write the same sector many times, but compatible with existing ms-sys */ /* May read/write the same sector many times, but compatible with existing ms-sys */
int write_data(FILE *fp, unsigned long ulPosition, int write_data(FILE *fp, size_t Position,
const void *pData, unsigned int uiLen) const void *pData, size_t Len)
{ {
unsigned char aucBuf[MAX_DATA_LEN]; unsigned char aucBuf[MAX_DATA_LEN];
HANDLE hDrive = (HANDLE)fp->_ptr; HANDLE hDrive = (HANDLE)fp->_ptr;
unsigned long ulSectorSize = (unsigned long)fp->_bufsiz; size_t SectorSize = (size_t)fp->_bufsiz;
unsigned long ulStartSector, ulEndSector, ulNumSectors; size_t StartSector, EndSector, NumSectors;
ulStartSector = ulPosition/ulSectorSize; StartSector = Position/SectorSize;
ulEndSector = (ulPosition+uiLen+ulSectorSize-1)/ulSectorSize; EndSector = (Position+Len+SectorSize-1)/SectorSize;
ulNumSectors = ulEndSector - ulStartSector; NumSectors = EndSector - StartSector;
if((ulNumSectors*ulSectorSize) > MAX_DATA_LEN) if((NumSectors*SectorSize) > MAX_DATA_LEN)
{ {
uprintf("Please increase MAX_DATA_LEN in file.h\n"); uprintf("Please increase MAX_DATA_LEN in file.h\n");
return 0; return 0;
} }
/* Data to write may not be aligned on a sector boundary => read into a sector buffer first */ /* Data to write may not be aligned on a sector boundary => read into a sector buffer first */
if(!read_sectors(hDrive, ulSectorSize, ulStartSector, if(!read_sectors(hDrive, SectorSize, StartSector,
ulNumSectors, aucBuf, sizeof(aucBuf))) NumSectors, aucBuf, sizeof(aucBuf)))
return 0; return 0;
if(!memcpy(&aucBuf[ulPosition - ulStartSector*ulSectorSize], pData, uiLen)) if(!memcpy(&aucBuf[Position - StartSector*SectorSize], pData, Len))
return 0; return 0;
if(!write_sectors(hDrive, ulSectorSize, ulStartSector, if(!write_sectors(hDrive, SectorSize, StartSector,
ulNumSectors, aucBuf, sizeof(aucBuf))) NumSectors, aucBuf, sizeof(aucBuf)))
return 0; return 0;
return 1; return 1;
} /* write_data */ } /* write_data */

View File

@ -6,13 +6,13 @@
/* Checks if a file contains a data pattern of length uiLen at position /* Checks if a file contains a data pattern of length uiLen at position
ulPositoin. The file pointer will change when calling this function! */ ulPositoin. The file pointer will change when calling this function! */
int contains_data(FILE *fp, unsigned long ulPosition, int contains_data(FILE *fp, size_t ulPosition,
const void *pData, unsigned int uiLen); const void *pData, size_t uiLen);
/* Writes a data pattern of length uiLen at position ulPositoin. /* Writes a data pattern of length uiLen at position ulPositoin.
The file pointer will change when calling this function! */ The file pointer will change when calling this function! */
int write_data(FILE *fp, unsigned long ulPosition, int write_data(FILE *fp, size_t ulPosition,
const void *pData, unsigned int uiLen); const void *pData, size_t uiLen);
/* Checks if a file contains a data pattern of length uiLen at position /* Checks if a file contains a data pattern of length uiLen at position
ulPositoin. The file pointer will change when calling this function! */ ulPositoin. The file pointer will change when calling this function! */

View File

@ -63,7 +63,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""https://github.com/pbatard/rufus/wiki/Rufus"">https://github.com/pbatard/rufus</a>",IDC_ABOUT_RUFUS_URL, CONTROL "<a href=""https://github.com/pbatard/rufus/wiki/Rufus"">https://github.com/pbatard/rufus</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9 "SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.0.0 (Build 55)",IDC_STATIC,46,19,78,8 LTEXT "Version 1.0.0 (Build 56)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -162,8 +162,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,55 FILEVERSION 1,0,0,56
PRODUCTVERSION 1,0,0,55 PRODUCTVERSION 1,0,0,56
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -180,13 +180,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "akeo.ie" VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.0.0.55" VALUE "FileVersion", "1.0.0.56"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.0.0.55" VALUE "ProductVersion", "1.0.0.56"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
@ -212,7 +212,7 @@ IDI_ICON ICON "rufus.ico"
STRINGTABLE STRINGTABLE
BEGIN BEGIN
IDS_VERSION "Rufus v1.0.0.55" IDS_VERSION "Rufus v1.0.0.56"
END END
#endif // English resources #endif // English resources