From 51569d9e13b7a055e78eea875270481440774828 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 8 Jan 2024 14:01:30 +0000 Subject: [PATCH] [misc] silence Coverity warnings * Also update copyright year and improve uprintf error handling * Also bump GitHub Actions dependencies. Note that we do NOT want to update to upload-artifact v4 because it BREAKS the creation of artifacts from matrix. See: https://github.com/actions/upload-artifact#v4---whats-new * Closes #2382 * Closes #2383 --- .github/workflows/codeql.yml | 4 ++-- src/localization_data.sh | 2 +- src/process.c | 11 +++++++---- src/rufus.rc | 12 ++++++------ src/stdio.c | 19 +++++++++++++++---- src/stdlg.c | 4 ++-- 6 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6fc37b76..279e1899 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -43,7 +43,7 @@ jobs: uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: cpp @@ -56,4 +56,4 @@ jobs: run: msbuild ${{env.SOLUTION_FILE_PATH}} /m /p:Configuration=${{ env.BUILD_CONFIGURATION}},Platform=${{ env.TARGET_PLATFORM }} - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/src/localization_data.sh b/src/localization_data.sh index c2a9ce71..b9568e34 100755 --- a/src/localization_data.sh +++ b/src/localization_data.sh @@ -12,7 +12,7 @@ cat > cmd.sed <<\_EOF 1i /*\ * Rufus: The Reliable USB Formatting Utility\ * Localization tables - autogenerated from resource.h\ - * Copyright © 2013-2023 Pete Batard \ + * Copyright © 2013-2024 Pete Batard \ *\ * This program is free software: you can redistribute it and/or modify\ * it under the terms of the GNU General Public License as published by\ diff --git a/src/process.c b/src/process.c index 00f8e670..9511808e 100644 --- a/src/process.c +++ b/src/process.c @@ -4,7 +4,7 @@ * * Modified from System Informer (a.k.a. Process Hacker): * https://github.com/winsiderss/systeminformer - * Copyright © 2017-2023 Pete Batard + * Copyright © 2017-2024 Pete Batard * Copyright © 2017 dmex * Copyright © 2009-2016 wj32 * @@ -589,6 +589,7 @@ static DWORD WINAPI SearchProcessThread(LPVOID param) pe[j].seen_on_pass = blocking_process.nPass; static_strcpy(pe[j].cmdline, cmdline); } else if (usb_debug) { + // coverity[dont_call] OutputDebugStringA("SearchProcessThread: No empty slot!\n"); } ReleaseMutex(hLock); @@ -726,10 +727,12 @@ static DWORD WINAPI SearchProcessThread(LPVOID param) // We are the only ones updating the counter so no need for lock blocking_process.nPass++; // In extended debug mode, notify how much time our search took to the debug facility - static_sprintf(tmp, "Process search run #%d completed in %llu ms\n", - blocking_process.nPass, GetTickCount64() - start_time); - if (usb_debug) + if (usb_debug) { + static_sprintf(tmp, "Process search run #%d completed in %llu ms\n", + blocking_process.nPass, GetTickCount64() - start_time); + // coverity[dont_call] OutputDebugStringA(tmp); + } Sleep(1000); } diff --git a/src/rufus.rc b/src/rufus.rc index f8d1391a..fda20577 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 4.4.2094" +CAPTION "Rufus 4.4.2096" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,4,2094,0 - PRODUCTVERSION 4,4,2094,0 + FILEVERSION 4,4,2096,0 + PRODUCTVERSION 4,4,2096,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.4.2094" + VALUE "FileVersion", "4.4.2096" VALUE "InternalName", "Rufus" - VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" + VALUE "LegalCopyright", "© 2011-2024 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.4.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.4.2094" + VALUE "ProductVersion", "4.4.2096" END END BLOCK "VarFileInfo" diff --git a/src/stdio.c b/src/stdio.c index 493345cf..bb9a682f 100644 --- a/src/stdio.c +++ b/src/stdio.c @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * Standard User I/O Routines (logging, status, error, etc.) - * Copyright © 2011-2023 Pete Batard + * Copyright © 2011-2024 Pete Batard * Copyright © 2020 Mattiwatti * * This program is free software: you can redistribute it and/or modify @@ -85,6 +85,7 @@ void uprintf(const char *format, ...) wbuf = utf8_to_wchar(buf); // Send output to Windows debug facility + // coverity[dont_call] OutputDebugStringW(wbuf); if ((hLog != NULL) && (hLog != INVALID_HANDLE_VALUE)) { // Send output to our log Window @@ -100,6 +101,7 @@ void uprintfs(const char* str) { wchar_t* wstr; wstr = utf8_to_wchar(str); + // coverity[dont_call] OutputDebugStringW(wstr); if ((hLog != NULL) && (hLog != INVALID_HANDLE_VALUE)) { Edit_SetSel(hLog, MAX_LOG_SIZE, MAX_LOG_SIZE); @@ -257,11 +259,20 @@ const char *WindowsErrorString(void) &err_string[presize], (DWORD)(sizeof(err_string)-strlen(err_string)), NULL); if (size == 0) { format_error = GetLastError(); - if ((format_error) && (format_error != ERROR_MR_MID_NOT_FOUND) && (format_error != ERROR_MUI_FILE_NOT_LOADED)) + switch (format_error) { + case ERROR_SUCCESS: + static_sprintf(err_string, "[0x%08lX] (No Windows Error String)", error_code); + break; + case ERROR_MR_MID_NOT_FOUND: + case ERROR_MUI_FILE_NOT_FOUND: + case ERROR_MUI_FILE_NOT_LOADED: + static_sprintf(err_string, "[0x%08lX] (NB: This system was unable to provide an English error message)", error_code); + break; + default: static_sprintf(err_string, "[0x%08lX] (FormatMessage error code 0x%08lX)", error_code, format_error); - else - static_sprintf(err_string, "[0x%08lX] (No Windows Error String)", error_code); + break; + } } else { // Microsoft may suffix CRLF to error messages, which we need to remove... assert(presize > 2); diff --git a/src/stdlg.c b/src/stdlg.c index 012a38b6..11450198 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -1,7 +1,7 @@ /* * Rufus: The Reliable USB Formatting Utility * Standard Dialog Routines (Browse for folder, About, etc) - * Copyright © 2011-2023 Pete Batard + * Copyright © 2011-2024 Pete Batard * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -386,7 +386,7 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP ResizeButtonHeight(hDlg, IDOK); static_sprintf(about_blurb, about_blurb_format, lmprintf(MSG_174|MSG_RTF), lmprintf(MSG_175|MSG_RTF, rufus_version[0], rufus_version[1], rufus_version[2]), - "Copyright © 2011-2023 Pete Batard", + "Copyright © 2011-2024 Pete Batard", lmprintf(MSG_176|MSG_RTF), lmprintf(MSG_177|MSG_RTF), lmprintf(MSG_178|MSG_RTF)); for (i = 0; i < ARRAYSIZE(hEdit); i++) { hEdit[i] = GetDlgItem(hDlg, edit_id[i]);