From 8506e47fd33fb3d0be5c2613519f93ed3f9207de Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Fri, 30 Nov 2012 00:18:28 +0000 Subject: [PATCH] [misc] fix Clang warnings --- src/dos.c | 2 +- src/libcdio/udf/udf_fs.c | 5 +++-- src/parser.c | 3 ++- src/rufus.c | 6 +++--- src/rufus.rc | 10 +++++----- src/stdlg.c | 3 ++- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/dos.c b/src/dos.c index 9c4d68cf..26eaffad 100644 --- a/src/dos.c +++ b/src/dos.c @@ -410,7 +410,7 @@ BOOL ExtractFreeDOS(const char* path) res_data = (BYTE*)LockResource(res_handle); res_size = SizeofResource(NULL, res); - strcpy(filename, (i<2)?path:locale_path); + safe_strcpy(filename, sizeof(filename), (i<2)?path:locale_path); safe_strcat(filename, sizeof(filename), "\\"); safe_strcat(filename, sizeof(filename), res_name[i]); diff --git a/src/libcdio/udf/udf_fs.c b/src/libcdio/udf/udf_fs.c index c4eb2bb6..749fd882 100644 --- a/src/libcdio/udf/udf_fs.c +++ b/src/libcdio/udf/udf_fs.c @@ -207,7 +207,7 @@ static udf_dirent_t * udf_ff_traverse(udf_dirent_t *p_udf_dirent, char *psz_token) { - while (udf_readdir(p_udf_dirent)) { + while ((p_udf_dirent = udf_readdir(p_udf_dirent))) { if (strcmp(psz_token, p_udf_dirent->psz_name) == 0) { char *next_tok = strtok(NULL, udf_PATH_DELIMITERS); @@ -226,7 +226,8 @@ udf_ff_traverse(udf_dirent_t *p_udf_dirent, char *psz_token) } } } - free(p_udf_dirent->psz_name); + if (p_udf_dirent) + free(p_udf_dirent->psz_name); return NULL; } diff --git a/src/parser.c b/src/parser.c index 44903faa..76306dee 100644 --- a/src/parser.c +++ b/src/parser.c @@ -53,7 +53,7 @@ static wchar_t* get_token_data_line(const wchar_t* wtoken, wchar_t* wline) const wchar_t wspace[] = L" \t"; // The only whitespaces we recognize as such const wchar_t weol[] = L"\r\n"; size_t i, r; - BOOLEAN quoteth; + BOOLEAN quoteth = FALSE; if ((wtoken == NULL) || (wline == NULL) || (wline[0] == 0)) return NULL; @@ -230,6 +230,7 @@ void parse_update(char* buf, size_t len) } } + for (i=0; i<4; i++) update.version[i] = 0; if ((data = get_sanitized_token_data_buffer("version", 1, buf, len)) != NULL) { for (i=0; (i<4) && ((token = strtok((i==0)?data:NULL, ".")) != NULL); i++) { update.version[i] = (uint8_t)atoi(token); diff --git a/src/rufus.c b/src/rufus.c index df36d248..481c4e0d 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -380,7 +380,6 @@ static BOOL GetDriveInfo(void) if (!r || size <= 0) { uprintf("IOCTL_DISK_GET_DRIVE_LAYOUT_EX failed for drive %c: %s\n", DrivePath[0], WindowsErrorString()); } else { - r = FALSE; switch (DriveLayout->PartitionStyle) { case PARTITION_STYLE_MBR: for (tmp_pos=0, i=0; (iPartitionCount)&&(tmp_pos>=0); i++) { @@ -1098,7 +1097,7 @@ BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) HFONT hf; long lfHeight; DWORD log_size; - char *log_buffer, *filepath; + char *log_buffer = NULL, *filepath; switch (message) { case WM_INITDIALOG: @@ -1124,7 +1123,8 @@ BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) return TRUE; case IDC_LOG_SAVE: log_size = GetWindowTextLengthU(hLog); - log_buffer = (char*)malloc(log_size); + if (log_size > 0) + log_buffer = (char*)malloc(log_size); if (log_buffer != NULL) { log_size = GetDlgItemTextU(hDlg, IDC_LOG_EDIT, log_buffer, log_size); if (log_size == 0) { diff --git a/src/rufus.rc b/src/rufus.rc index cb7fc918..cc318420 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 316 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.2.1.199" +CAPTION "Rufus v1.2.1.200" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,278,50,14 @@ -248,8 +248,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,2,1,199 - PRODUCTVERSION 1,2,1,199 + FILEVERSION 1,2,1,200 + PRODUCTVERSION 1,2,1,200 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -266,13 +266,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.2.1.199" + VALUE "FileVersion", "1.2.1.200" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "(c) 2011-2012 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.2.1.199" + VALUE "ProductVersion", "1.2.1.200" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index 62ddffd1..253e16be 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -141,7 +141,8 @@ void StrArrayClear(StrArray* arr) void StrArrayDestroy(StrArray* arr) { StrArrayClear(arr); - safe_free(arr->Table); + if (arr != NULL) + safe_free(arr->Table); } /*