mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Static Code Analysis: handle unused variables more properly. Catch STL exception. Add more checks. Add proper cast to arithmetic operations.
This commit is contained in:
@@ -27,8 +27,8 @@
|
|||||||
not. - see DialogProc */
|
not. - see DialogProc */
|
||||||
BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (lParam); /* remove warning */
|
UNREFERENCED_PARAMETER (lParam); /* remove warning */
|
||||||
if (wParam); /* remove warning */
|
UNREFERENCED_PARAMETER (wParam); /* remove warning */
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ void LoadCombo (HWND hComboBox)
|
|||||||
void DumpCombo (HWND hComboBox, int bClear)
|
void DumpCombo (HWND hComboBox, int bClear)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int i, nComboIdx[SIZEOF_MRU_LIST];
|
int i, nComboIdx[SIZEOF_MRU_LIST] = {0};
|
||||||
|
|
||||||
if (bClear)
|
if (bClear)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,11 +22,15 @@ static size_t DataPoolSize = 0;
|
|||||||
|
|
||||||
void AddDictionaryEntry (char *key, int intKey, void *value)
|
void AddDictionaryEntry (char *key, int intKey, void *value)
|
||||||
{
|
{
|
||||||
if (key)
|
try
|
||||||
StringKeyMap[key] = value;
|
{
|
||||||
|
if (key)
|
||||||
|
StringKeyMap[key] = value;
|
||||||
|
|
||||||
if (intKey != 0)
|
if (intKey != 0)
|
||||||
IntKeyMap[intKey] = value;
|
IntKeyMap[intKey] = value;
|
||||||
|
}
|
||||||
|
catch (exception&) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ GetFatParams (fatparams * ft)
|
|||||||
if (ft->cluster_size == 0)
|
if (ft->cluster_size == 0)
|
||||||
ft->cluster_size = 1;
|
ft->cluster_size = 1;
|
||||||
|
|
||||||
if (ft->cluster_size * ft->sector_size > TC_MAX_FAT_CLUSTER_SIZE)
|
if (((unsigned __int64) ft->cluster_size * ft->sector_size) > TC_MAX_FAT_CLUSTER_SIZE)
|
||||||
ft->cluster_size = TC_MAX_FAT_CLUSTER_SIZE / ft->sector_size;
|
ft->cluster_size = TC_MAX_FAT_CLUSTER_SIZE / ft->sector_size;
|
||||||
|
|
||||||
if (ft->cluster_size > 128)
|
if (ft->cluster_size > 128)
|
||||||
@@ -85,7 +85,7 @@ GetFatParams (fatparams * ft)
|
|||||||
ft->size_fat = 12;
|
ft->size_fat = 12;
|
||||||
ft->reserved = 2;
|
ft->reserved = 2;
|
||||||
fatsecs = ft->num_sectors - (ft->size_root_dir + ft->sector_size - 1) / ft->sector_size - ft->reserved;
|
fatsecs = ft->num_sectors - (ft->size_root_dir + ft->sector_size - 1) / ft->sector_size - ft->reserved;
|
||||||
ft->cluster_count = (int) (((__int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
|
ft->cluster_count = (int) (((unsigned __int64) fatsecs * ft->sector_size) / ((unsigned __int64) ft->cluster_size * ft->sector_size));
|
||||||
ft->fat_length = (((ft->cluster_count * 3 + 1) >> 1) + ft->sector_size - 1) / ft->sector_size;
|
ft->fat_length = (((ft->cluster_count * 3 + 1) >> 1) + ft->sector_size - 1) / ft->sector_size;
|
||||||
|
|
||||||
if (ft->cluster_count >= 4085) // FAT16
|
if (ft->cluster_count >= 4085) // FAT16
|
||||||
@@ -108,7 +108,7 @@ GetFatParams (fatparams * ft)
|
|||||||
|
|
||||||
fatsecs = ft->num_sectors - ft->reserved;
|
fatsecs = ft->num_sectors - ft->reserved;
|
||||||
ft->size_root_dir = ft->cluster_size * ft->sector_size;
|
ft->size_root_dir = ft->cluster_size * ft->sector_size;
|
||||||
ft->cluster_count = (int) (((__int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
|
ft->cluster_count = (int) (((unsigned __int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
|
||||||
ft->fat_length = (ft->cluster_count * 4 + ft->sector_size - 1) / ft->sector_size;
|
ft->fat_length = (ft->cluster_count * 4 + ft->sector_size - 1) / ft->sector_size;
|
||||||
|
|
||||||
// Align data area on TC_MAX_VOLUME_SECTOR_SIZE
|
// Align data area on TC_MAX_VOLUME_SECTOR_SIZE
|
||||||
@@ -282,7 +282,8 @@ FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void
|
|||||||
|
|
||||||
memset (sector, 0, ft->sector_size);
|
memset (sector, 0, ft->sector_size);
|
||||||
|
|
||||||
RandgetBytes (hwndDlg, ft->volume_id, sizeof (ft->volume_id), FALSE);
|
if (!RandgetBytes (hwndDlg, ft->volume_id, sizeof (ft->volume_id), FALSE))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
PutBoot (ft, (unsigned char *) sector);
|
PutBoot (ft, (unsigned char *) sector);
|
||||||
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ typedef struct fatparams_t
|
|||||||
int size_fat; /* size of FAT */
|
int size_fat; /* size of FAT */
|
||||||
int fats;
|
int fats;
|
||||||
int media;
|
int media;
|
||||||
int cluster_size;
|
unsigned int cluster_size;
|
||||||
int fat_length;
|
int fat_length;
|
||||||
uint16 dir_entries;
|
uint16 dir_entries;
|
||||||
uint16 sector_size;
|
uint16 sector_size;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ typedef struct
|
|||||||
int pkcs5;
|
int pkcs5;
|
||||||
uint32 headerFlags;
|
uint32 headerFlags;
|
||||||
int fileSystem;
|
int fileSystem;
|
||||||
int clusterSize;
|
unsigned int clusterSize;
|
||||||
BOOL sparseFileSwitch;
|
BOOL sparseFileSwitch;
|
||||||
BOOL quickFormat;
|
BOOL quickFormat;
|
||||||
int sectorSize;
|
int sectorSize;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ static char *MapNextLanguageFile ()
|
|||||||
WIN32_FIND_DATAW find;
|
WIN32_FIND_DATAW find;
|
||||||
HANDLE file;
|
HANDLE file;
|
||||||
DWORD read;
|
DWORD read;
|
||||||
|
BOOL bStatus;
|
||||||
|
|
||||||
if (LanguageFileFindHandle == INVALID_HANDLE_VALUE)
|
if (LanguageFileFindHandle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@@ -107,9 +108,9 @@ static char *MapNextLanguageFile ()
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadFile (file, LanguageFileBuffer, find.nFileSizeLow, &read, NULL);
|
bStatus = ReadFile (file, LanguageFileBuffer, find.nFileSizeLow, &read, NULL);
|
||||||
CloseHandle (file);
|
CloseHandle (file);
|
||||||
if (read != find.nFileSizeLow)
|
if (!bStatus || (read != find.nFileSizeLow))
|
||||||
{
|
{
|
||||||
free(LanguageFileBuffer);
|
free(LanguageFileBuffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void VerifyPasswordAndUpdate (HWND hwndDlg, HWND hButton, HWND hPassword,
|
|||||||
int k = GetWindowTextLength (hPassword);
|
int k = GetWindowTextLength (hPassword);
|
||||||
BOOL bEnable = FALSE;
|
BOOL bEnable = FALSE;
|
||||||
|
|
||||||
if (hwndDlg); /* Remove warning */
|
UNREFERENCED_PARAMETER (hwndDlg); /* Remove warning */
|
||||||
|
|
||||||
GetWindowText (hPassword, szTmp1, sizeof (szTmp1));
|
GetWindowText (hPassword, szTmp1, sizeof (szTmp1));
|
||||||
GetWindowText (hVerify, szTmp2, sizeof (szTmp2));
|
GetWindowText (hVerify, szTmp2, sizeof (szTmp2));
|
||||||
|
|||||||
@@ -534,7 +534,7 @@ LRESULT CALLBACK KeyboardProc (int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
/* This is the thread function which will poll the system for randomness */
|
/* This is the thread function which will poll the system for randomness */
|
||||||
static unsigned __stdcall PeriodicFastPollThreadProc (void *dummy)
|
static unsigned __stdcall PeriodicFastPollThreadProc (void *dummy)
|
||||||
{
|
{
|
||||||
if (dummy); /* Remove unused parameter warning */
|
UNREFERENCED_PARAMETER (dummy); /* Remove unused parameter warning */
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -817,7 +817,6 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
{
|
{
|
||||||
static UINT taskBarCreatedMsg;
|
static UINT taskBarCreatedMsg;
|
||||||
WORD lw = LOWORD (wParam);
|
WORD lw = LOWORD (wParam);
|
||||||
WORD hw = HIWORD (wParam);
|
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user