William A. Kennington III | b95905d | 2021-06-02 12:40:56 -0700 | [diff] [blame] | 1 | From 653674e11872465dd5edf1c1e8413ea813d7e086 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 23 Apr 2018 23:07:21 -0700 |
| 4 | Subject: [PATCH] Fix narrowing errors -Wc++11-narrowing |
| 5 | |
| 6 | Clang 6.x finds these errors |
| 7 | |
| 8 | ../../../../CPP/Windows/ErrorMsg.cpp:24:10: error: case value evaluates to -2147024809, which cannot be narrowed to type 'DWORD' (aka 'unsigned int') [-Wc++11-narrowing] |
| 9 | case E_INVALIDARG : txt = "E_INVALIDARG"; break ; |
| 10 | ^ |
| 11 | |
| 12 | HRESULT causes the macro to be parsed as a signed long, so we need to force it |
| 13 | to be checked as an unsigned long instead. |
| 14 | |
| 15 | also reported here https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224930 |
| 16 | |
| 17 | Upstream-Status: Pending |
| 18 | |
| 19 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
William A. Kennington III | b95905d | 2021-06-02 12:40:56 -0700 | [diff] [blame] | 20 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 21 | --- |
| 22 | CPP/Windows/ErrorMsg.cpp | 14 +++++++------- |
| 23 | 1 file changed, 7 insertions(+), 7 deletions(-) |
| 24 | |
| 25 | diff --git a/CPP/Windows/ErrorMsg.cpp b/CPP/Windows/ErrorMsg.cpp |
| 26 | index 99684ae..78a64ba 100644 |
| 27 | --- a/CPP/Windows/ErrorMsg.cpp |
| 28 | +++ b/CPP/Windows/ErrorMsg.cpp |
| 29 | @@ -15,13 +15,13 @@ UString MyFormatMessage(DWORD errorCode) |
| 30 | |
| 31 | switch(errorCode) { |
| 32 | case ERROR_NO_MORE_FILES : txt = "No more files"; break ; |
| 33 | - case E_NOTIMPL : txt = "E_NOTIMPL"; break ; |
| 34 | - case E_NOINTERFACE : txt = "E_NOINTERFACE"; break ; |
| 35 | - case E_ABORT : txt = "E_ABORT"; break ; |
| 36 | - case E_FAIL : txt = "E_FAIL"; break ; |
| 37 | - case STG_E_INVALIDFUNCTION : txt = "STG_E_INVALIDFUNCTION"; break ; |
| 38 | - case E_OUTOFMEMORY : txt = "E_OUTOFMEMORY"; break ; |
| 39 | - case E_INVALIDARG : txt = "E_INVALIDARG"; break ; |
| 40 | + case (DWORD) E_NOTIMPL : txt = "E_NOTIMPL"; break ; |
| 41 | + case (DWORD) E_NOINTERFACE : txt = "E_NOINTERFACE"; break ; |
| 42 | + case (DWORD) E_ABORT : txt = "E_ABORT"; break ; |
| 43 | + case (DWORD) E_FAIL : txt = "E_FAIL"; break ; |
| 44 | + case (DWORD) STG_E_INVALIDFUNCTION : txt = "STG_E_INVALIDFUNCTION"; break ; |
| 45 | + case (DWORD) E_OUTOFMEMORY : txt = "E_OUTOFMEMORY"; break ; |
| 46 | + case (DWORD) E_INVALIDARG : txt = "E_INVALIDARG"; break ; |
| 47 | case ERROR_DIRECTORY : txt = "Error Directory"; break ; |
| 48 | default: |
| 49 | txt = strerror(errorCode); |