Merge pull request #10797 from akallabeth/warn-fixes

Warn fixes
This commit is contained in:
Martin Fleisz 2024-11-07 13:50:51 +01:00 committed by GitHub
commit 1520d94d33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 152 additions and 135 deletions

View File

@ -71,6 +71,7 @@ Checks: >
-readability-identifier-length, -readability-identifier-length,
-readability-implicit-bool-conversion, -readability-implicit-bool-conversion,
-readability-magic-numbers, -readability-magic-numbers,
-readability-math-missing-parentheses,
-readability-misleading-indentation, -readability-misleading-indentation,
-readability-qualified-auto, -readability-qualified-auto,
-readability-suspicious-call-argument, -readability-suspicious-call-argument,

View File

@ -119,8 +119,8 @@ disp_send_display_control_monitor_layout_pdu(GENERIC_CHANNEL_CALLBACK* callback,
current.Height = 8192; current.Height = 8192;
Stream_Write_UINT32(s, current.Flags); /* Flags (4 bytes) */ Stream_Write_UINT32(s, current.Flags); /* Flags (4 bytes) */
Stream_Write_UINT32(s, current.Left); /* Left (4 bytes) */ Stream_Write_INT32(s, current.Left); /* Left (4 bytes) */
Stream_Write_UINT32(s, current.Top); /* Top (4 bytes) */ Stream_Write_INT32(s, current.Top); /* Top (4 bytes) */
Stream_Write_UINT32(s, current.Width); /* Width (4 bytes) */ Stream_Write_UINT32(s, current.Width); /* Width (4 bytes) */
Stream_Write_UINT32(s, current.Height); /* Height (4 bytes) */ Stream_Write_UINT32(s, current.Height); /* Height (4 bytes) */
Stream_Write_UINT32(s, current.PhysicalWidth); /* PhysicalWidth (4 bytes) */ Stream_Write_UINT32(s, current.PhysicalWidth); /* PhysicalWidth (4 bytes) */

View File

@ -392,7 +392,7 @@ fail:
BOOL drive_file_seek(DRIVE_FILE* file, UINT64 Offset) BOOL drive_file_seek(DRIVE_FILE* file, UINT64 Offset)
{ {
LARGE_INTEGER loffset; LARGE_INTEGER loffset = { 0 };
if (!file) if (!file)
return FALSE; return FALSE;
@ -616,10 +616,10 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
{ {
INT64 size = 0; INT64 size = 0;
WCHAR* fullpath = NULL; WCHAR* fullpath = NULL;
ULARGE_INTEGER liCreationTime; ULARGE_INTEGER liCreationTime = { 0 };
ULARGE_INTEGER liLastAccessTime; ULARGE_INTEGER liLastAccessTime = { 0 };
ULARGE_INTEGER liLastWriteTime; ULARGE_INTEGER liLastWriteTime = { 0 };
ULARGE_INTEGER liChangeTime; ULARGE_INTEGER liChangeTime = { 0 };
FILETIME ftCreationTime; FILETIME ftCreationTime;
FILETIME ftLastAccessTime; FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime; FILETIME ftLastWriteTime;
@ -628,7 +628,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
FILETIME* pftLastWriteTime = NULL; FILETIME* pftLastWriteTime = NULL;
UINT32 FileAttributes = 0; UINT32 FileAttributes = 0;
UINT32 FileNameLength = 0; UINT32 FileNameLength = 0;
LARGE_INTEGER liSize; LARGE_INTEGER liSize = { 0 };
UINT8 delete_pending = 0; UINT8 delete_pending = 0;
UINT8 ReplaceIfExists = 0; UINT8 ReplaceIfExists = 0;
DWORD attr = 0; DWORD attr = 0;

View File

@ -293,10 +293,10 @@ static UINT rdpgfx_send_reset_graphics_pdu(RdpgfxServerContext* context,
for (UINT32 index = 0; index < pdu->monitorCount; index++) for (UINT32 index = 0; index < pdu->monitorCount; index++)
{ {
const MONITOR_DEF* monitor = &(pdu->monitorDefArray[index]); const MONITOR_DEF* monitor = &(pdu->monitorDefArray[index]);
Stream_Write_UINT32(s, monitor->left); /* left (4 bytes) */ Stream_Write_INT32(s, monitor->left); /* left (4 bytes) */
Stream_Write_UINT32(s, monitor->top); /* top (4 bytes) */ Stream_Write_INT32(s, monitor->top); /* top (4 bytes) */
Stream_Write_UINT32(s, monitor->right); /* right (4 bytes) */ Stream_Write_INT32(s, monitor->right); /* right (4 bytes) */
Stream_Write_UINT32(s, monitor->bottom); /* bottom (4 bytes) */ Stream_Write_INT32(s, monitor->bottom); /* bottom (4 bytes) */
Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */ Stream_Write_UINT32(s, monitor->flags); /* flags (4 bytes) */
} }

View File

@ -493,9 +493,9 @@ static UINT urb_select_configuration(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* c
if (MsOutSize > 0) if (MsOutSize > 0)
{ {
/** CbTsUrbResult */ /** CbTsUrbResult */
Stream_Write_UINT32(out, 8 + MsOutSize); Stream_Write_UINT32(out, 8U + (UINT32)MsOutSize);
/** TS_URB_RESULT_HEADER Size*/ /** TS_URB_RESULT_HEADER Size*/
Stream_Write_UINT16(out, 8 + MsOutSize); Stream_Write_UINT16(out, 8U + (UINT32)MsOutSize);
} }
else else
{ {

View File

@ -36,10 +36,7 @@ SdlButton::SdlButton(SDL_Renderer* renderer, std::string label, int id, SDL_Rect
update_text(renderer, _name, buttonfontcolor, buttonbackgroundcolor); update_text(renderer, _name, buttonfontcolor, buttonbackgroundcolor);
} }
SdlButton::SdlButton(SdlButton&& other) noexcept SdlButton::SdlButton(SdlButton&& other) noexcept = default;
: SdlWidget(std::move(other)), _name(std::move(other._name)), _id(other._id)
{
}
SdlButton::~SdlButton() = default; SdlButton::~SdlButton() = default;

View File

@ -284,6 +284,7 @@ int SdlInputWidgetList::run(std::vector<std::string>& result)
} }
catch (...) catch (...)
{ {
res = -2;
} }
return res; return res;

View File

@ -42,11 +42,7 @@ SdlSelectWidget::SdlSelectWidget(SDL_Renderer* renderer, std::string label, SDL_
update_text(renderer); update_text(renderer);
} }
SdlSelectWidget::SdlSelectWidget(SdlSelectWidget&& other) noexcept SdlSelectWidget::SdlSelectWidget(SdlSelectWidget&& other) noexcept = default;
: SdlWidget(std::move(other)), _text(std::move(other._text)), _mouseover(other._mouseover),
_highlight(other._highlight)
{
}
SdlSelectWidget::~SdlSelectWidget() = default; SdlSelectWidget::~SdlSelectWidget() = default;

View File

@ -213,7 +213,7 @@ BOOL sdl_push_user_event(Uint32 type, ...)
event->data2 = va_arg(ap, void*); event->data2 = va_arg(ap, void*);
break; break;
case SDL_USEREVENT_CREATE_WINDOWS: case SDL_USEREVENT_CREATE_WINDOWS:
event->data1 = reinterpret_cast<void*>(va_arg(ap, void*)); event->data1 = va_arg(ap, void*);
break; break;
case SDL_USEREVENT_WINDOW_FULLSCREEN: case SDL_USEREVENT_WINDOW_FULLSCREEN:
case SDL_USEREVENT_WINDOW_RESIZEABLE: case SDL_USEREVENT_WINDOW_RESIZEABLE:

View File

@ -36,10 +36,7 @@ SdlButton::SdlButton(SDL_Renderer* renderer, std::string label, int id, const SD
update_text(renderer, _name, buttonfontcolor, buttonbackgroundcolor); update_text(renderer, _name, buttonfontcolor, buttonbackgroundcolor);
} }
SdlButton::SdlButton(SdlButton&& other) noexcept SdlButton::SdlButton(SdlButton&& other) noexcept = default;
: SdlWidget(std::move(other)), _name(std::move(other._name)), _id(other._id)
{
}
SdlButton::~SdlButton() = default; SdlButton::~SdlButton() = default;

View File

@ -284,6 +284,7 @@ int SdlInputWidgetList::run(std::vector<std::string>& result)
} }
catch (...) catch (...)
{ {
res = -2;
} }
return res; return res;

View File

@ -42,11 +42,7 @@ SdlSelectWidget::SdlSelectWidget(SDL_Renderer* renderer, std::string label, cons
update_text(renderer); update_text(renderer);
} }
SdlSelectWidget::SdlSelectWidget(SdlSelectWidget&& other) noexcept SdlSelectWidget::SdlSelectWidget(SdlSelectWidget&& other) noexcept = default;
: SdlWidget(std::move(other)), _text(std::move(other._text)), _mouseover(other._mouseover),
_highlight(other._highlight)
{
}
bool SdlSelectWidget::set_mouseover(SDL_Renderer* renderer, bool mouseOver) bool SdlSelectWidget::set_mouseover(SDL_Renderer* renderer, bool mouseOver)
{ {

View File

@ -1731,8 +1731,8 @@ BOOL SdlContext::update_resizeable(BOOL enable)
} }
SdlContext::SdlContext(rdpContext* context) SdlContext::SdlContext(rdpContext* context)
: _context(context), log(WLog_Get(SDL_TAG)), update_complete(true), disp(this), clip(this), : _context(context), log(WLog_Get(SDL_TAG)), update_complete(true), disp(this), input(this),
input(this), primary(nullptr, SDL_DestroySurface), rdp_thread_running(false) clip(this), primary(nullptr, SDL_DestroySurface), rdp_thread_running(false)
{ {
WINPR_ASSERT(context); WINPR_ASSERT(context);
grab_kbd_enabled = freerdp_settings_get_bool(context->settings, FreeRDP_GrabKeyboard); grab_kbd_enabled = freerdp_settings_get_bool(context->settings, FreeRDP_GrabKeyboard);

View File

@ -259,7 +259,7 @@ BOOL sdl_push_user_event(Uint32 type, ...)
event->data2 = va_arg(ap, void*); event->data2 = va_arg(ap, void*);
break; break;
case SDL_EVENT_USER_CREATE_WINDOWS: case SDL_EVENT_USER_CREATE_WINDOWS:
event->data1 = reinterpret_cast<void*>(va_arg(ap, void*)); event->data1 = va_arg(ap, void*);
break; break;
case SDL_EVENT_USER_WINDOW_FULLSCREEN: case SDL_EVENT_USER_WINDOW_FULLSCREEN:
case SDL_EVENT_USER_WINDOW_RESIZEABLE: case SDL_EVENT_USER_WINDOW_RESIZEABLE:

View File

@ -478,7 +478,7 @@ static int wlfreerdp_run(freerdp* instance)
HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 }; HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 };
DWORD status = WAIT_ABANDONED; DWORD status = WAIT_ABANDONED;
HANDLE timer = NULL; HANDLE timer = NULL;
LARGE_INTEGER due; LARGE_INTEGER due = { 0 };
TimerEventArgs timerEvent; TimerEventArgs timerEvent;
EventArgsInit(&timerEvent, "xfreerdp"); EventArgsInit(&timerEvent, "xfreerdp");

View File

@ -202,8 +202,6 @@ if (WITH_XFIXES)
endif() endif()
endif() endif()
include_directories(${PROJECT_SOURCE_DIR}/resources)
list(APPEND PUB_LIBS list(APPEND PUB_LIBS
freerdp-client freerdp-client
) )

View File

@ -1034,7 +1034,7 @@ static int freerdp_client_command_line_post_filter_int(void* context, COMMAND_LI
size_t count = 0; size_t count = 0;
char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count); char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
if (!freerdp_client_add_device_channel(settings, count, (const char**)ptr)) if (!freerdp_client_add_device_channel(settings, count, (const char* const*)ptr))
status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE; status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE)) if (!freerdp_settings_set_bool(settings, FreeRDP_DeviceRedirection, TRUE))
status = COMMAND_LINE_ERROR; status = COMMAND_LINE_ERROR;

View File

@ -2310,7 +2310,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett
size_t count = 0; size_t count = 0;
char** ptr = CommandLineParseCommaSeparatedValuesEx(LOCATION_CHANNEL_NAME, NULL, &count); char** ptr = CommandLineParseCommaSeparatedValuesEx(LOCATION_CHANNEL_NAME, NULL, &count);
const BOOL rc = freerdp_client_add_dynamic_channel(settings, count, (const char**)ptr); const BOOL rc =
freerdp_client_add_dynamic_channel(settings, count, (const char* const*)ptr);
CommandLineParserFree(ptr); CommandLineParserFree(ptr);
if (!rc) if (!rc)
return FALSE; return FALSE;

View File

@ -1030,9 +1030,9 @@ static BOOL http_response_parse_header(HttpResponse* response)
break; break;
} }
const int rc = http_response_parse_header_field(response, name, value); const int res = http_response_parse_header_field(response, name, value);
*end_of_header = end_of_header_char; *end_of_header = end_of_header_char;
if (!rc) if (!res)
goto fail; goto fail;
} }

View File

@ -2626,8 +2626,8 @@ static BOOL update_send_new_or_existing_window(rdpContext* context,
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) != 0) if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET) != 0)
{ {
Stream_Write_UINT32(s, stateOrder->visibleOffsetX); Stream_Write_INT32(s, stateOrder->visibleOffsetX);
Stream_Write_UINT32(s, stateOrder->visibleOffsetY); Stream_Write_INT32(s, stateOrder->visibleOffsetY);
} }
if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) != 0) if ((orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) != 0)

View File

@ -410,13 +410,13 @@ int er_write_integer(wStream* s, INT32 value)
else if (value <= 32767 && value >= -32768) else if (value <= 32767 && value >= -32768)
{ {
er_write_length(s, 2, FALSE); er_write_length(s, 2, FALSE);
Stream_Write_UINT16_BE(s, value); Stream_Write_INT16_BE(s, value);
return 3; return 3;
} }
else else
{ {
er_write_length(s, 4, FALSE); er_write_length(s, 4, FALSE);
Stream_Write_UINT32_BE(s, value); Stream_Write_INT32_BE(s, value);
return 5; return 5;
} }
} }

View File

@ -287,7 +287,7 @@ static void keyboard_handle_leave(void* data, struct wl_keyboard* keyboard, uint
its.it_interval.tv_nsec = 0; its.it_interval.tv_nsec = 0;
its.it_value.tv_sec = 0; its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 0; its.it_value.tv_nsec = 0;
timerfd_settime(input->repeat_timer_fd, 0, &its, NULL); (void)timerfd_settime(input->repeat_timer_fd, 0, &its, NULL);
UwacPointerEnterLeaveEvent* event = UwacPointerEnterLeaveEvent* event =
(UwacPointerEnterLeaveEvent*)UwacDisplayNewEvent(input->display, UWAC_EVENT_POINTER_LEAVE); (UwacPointerEnterLeaveEvent*)UwacDisplayNewEvent(input->display, UWAC_EVENT_POINTER_LEAVE);
@ -403,7 +403,7 @@ static void keyboard_handle_key(void* data, struct wl_keyboard* keyboard, uint32
its.it_interval.tv_nsec = 0; its.it_interval.tv_nsec = 0;
its.it_value.tv_sec = 0; its.it_value.tv_sec = 0;
its.it_value.tv_nsec = 0; its.it_value.tv_nsec = 0;
timerfd_settime(input->repeat_timer_fd, 0, &its, NULL); (void)timerfd_settime(input->repeat_timer_fd, 0, &its, NULL);
} }
else if (state == WL_KEYBOARD_KEY_STATE_PRESSED && else if (state == WL_KEYBOARD_KEY_STATE_PRESSED &&
xkb_keymap_key_repeats(input->xkb.keymap, code)) xkb_keymap_key_repeats(input->xkb.keymap, code))
@ -415,7 +415,7 @@ static void keyboard_handle_key(void* data, struct wl_keyboard* keyboard, uint32
its.it_interval.tv_nsec = input->repeat_rate_nsec; its.it_interval.tv_nsec = input->repeat_rate_nsec;
its.it_value.tv_sec = input->repeat_delay_sec; its.it_value.tv_sec = input->repeat_delay_sec;
its.it_value.tv_nsec = input->repeat_delay_nsec; its.it_value.tv_nsec = input->repeat_delay_nsec;
timerfd_settime(input->repeat_timer_fd, 0, &its, NULL); (void)timerfd_settime(input->repeat_timer_fd, 0, &its, NULL);
} }
keyEvent = (UwacKeyEvent*)UwacDisplayNewEvent(input->display, UWAC_EVENT_KEY); keyEvent = (UwacKeyEvent*)UwacDisplayNewEvent(input->display, UWAC_EVENT_KEY);

View File

@ -34,15 +34,19 @@
extern "C" extern "C"
{ {
#endif #endif
#define WINPR_ASSERT(cond) \ #define WINPR_ASSERT(cond) \
do \ do \
{ \ { \
WINPR_PRAGMA_DIAG_PUSH \ WINPR_PRAGMA_DIAG_PUSH \
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \ WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \ WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
if (!(cond)) \ WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
winpr_int_assert(#cond, __FILE__, __func__, __LINE__); \ WINPR_DO_PRAGMA(coverity compliance deviate "NO_EFFECT:SUPPRESS" \
WINPR_PRAGMA_DIAG_POP \ "WINPR_ASSERT") \
\
if (!(cond)) \
winpr_int_assert(#cond, __FILE__, __func__, __LINE__); \
WINPR_PRAGMA_DIAG_POP \
} while (0) } while (0)
static INLINE WINPR_NORETURN(void winpr_int_assert(const char* condstr, const char* file, static INLINE WINPR_NORETURN(void winpr_int_assert(const char* condstr, const char* file,
@ -59,15 +63,17 @@ extern "C"
#endif #endif
#else #else
#define WINPR_ASSERT(cond) \ #define WINPR_ASSERT(cond) \
do \ do \
{ \ { \
WINPR_PRAGMA_DIAG_PUSH \ WINPR_PRAGMA_DIAG_PUSH \
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \ WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \ WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
_Pragma("coverity compliance deviate \"NO_EFFECT:SUPPRESS\" \"WINPR_ASSERT\"") \ WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
assert(cond); \ WINPR_DO_PRAGMA(coverity compliance deviate "NO_EFFECT:SUPPRESS" \
WINPR_PRAGMA_DIAG_POP \ "WINPR_ASSERT") \
assert(cond); \
WINPR_PRAGMA_DIAG_POP \
} while (0) } while (0)
#endif #endif

View File

@ -22,7 +22,16 @@
#include <stdlib.h> #include <stdlib.h>
/* MSVC only defines _Pragma if you compile with /std:c11 with no extensions
* see
* https://learn.microsoft.com/en-us/cpp/preprocessor/pragma-directives-and-the-pragma-keyword?view=msvc-170#the-pragma-preprocessing-operator
*/
#if !defined(_MSC_VER)
#define WINPR_DO_PRAGMA(x) _Pragma(#x) #define WINPR_DO_PRAGMA(x) _Pragma(#x)
#else
#define WINPR_DO_PRAGMA(x) __pragma(#x)
#endif
#if defined(__GNUC__) #if defined(__GNUC__)
#define WINPR_PRAGMA_WARNING(msg) WINPR_DO_PRAGMA(GCC warning #msg) #define WINPR_PRAGMA_WARNING(msg) WINPR_DO_PRAGMA(GCC warning #msg)
#elif defined(__clang__) #elif defined(__clang__)
@ -60,93 +69,102 @@
#endif #endif
#if defined(__clang__) #if defined(__clang__)
#define WINPR_PRAGMA_DIAG_PUSH _Pragma("clang diagnostic push") #define WINPR_PRAGMA_DIAG_PUSH WINPR_DO_PRAGMA(clang diagnostic push)
#define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \ #define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \
_Pragma("clang diagnostic ignored \"-Woverlength-strings\"") /** @since version 3.9.0 */ WINPR_DO_PRAGMA(clang diagnostic ignored "-Woverlength-strings") /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS \ #define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS \
_Pragma("clang diagnostic ignored \"-Wdiscarded-qualifiers\"") /** @since version 3.9.0 */ WINPR_DO_PRAGMA(clang diagnostic ignored "-Wdiscarded-qualifiers") /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC _Pragma("clang diagnostic ignored \"-Wpedantic\"") #define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC WINPR_DO_PRAGMA(clang diagnostic ignored "-Wpedantic")
#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \ #define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \
_Pragma("clang diagnostic ignored \"-Wmissing-prototypes\"") WINPR_DO_PRAGMA(clang diagnostic ignored "-Wmissing-prototypes")
#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES \ #define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES \
_Pragma("clang diagnostic ignored \"-Wstrict-prototypes\"") WINPR_DO_PRAGMA(clang diagnostic ignored "-Wstrict-prototypes")
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO \ #define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO \
_Pragma("clang diagnostic ignored \"-Wreserved-id-macro\"") WINPR_DO_PRAGMA(clang diagnostic ignored "-Wreserved-id-macro")
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO \ #define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO \
_Pragma("clang diagnostic ignored \"-Wunused-macros\"") WINPR_DO_PRAGMA(clang diagnostic ignored "-Wunused-macros")
#define WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
WINPR_DO_PRAGMA(clang diagnostic ignored "-Wunknown-pragmas") /** @since version 3.10.0 */
#if __clang_major__ >= 13 #if __clang_major__ >= 13
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER \ #define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER \
_Pragma("clang diagnostic ignored \"-Wreserved-identifier\"") WINPR_DO_PRAGMA(clang diagnostic ignored "-Wreserved-identifier")
#else #else
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER #define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
#endif #endif
#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST \ #define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST \
_Pragma("clang diagnostic ignored \"-Watomic-implicit-seq-cst\"") WINPR_DO_PRAGMA(clang diagnostic ignored "-Watomic-implicit-seq-cst")
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR \ #define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR \
_Pragma("clang diagnostic ignored \"-Wunused-const-variable\"") WINPR_DO_PRAGMA(clang diagnostic ignored "-Wunused-const-variable")
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \ #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \
_Pragma("clang diagnostic ignored \"-Wformat-security\"") WINPR_DO_PRAGMA(clang diagnostic ignored "-Wformat-security")
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \ #define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE \
_Pragma("clang diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"") /** @since \ WINPR_DO_PRAGMA(clang diagnostic ignored \
version \ "-Wtautological-constant-out-of-range-compare") /** @since \
3.9.0 \ version \
*/ 3.9.0 \
*/
#if __clang_major__ >= 12 #if __clang_major__ >= 12
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \ #define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE \
_Pragma( \ WINPR_DO_PRAGMA(clang diagnostic ignored \
"clang diagnostic ignored \"-Wtautological-value-range-compare\"") /** @since \ "-Wtautological-value-range-compare") /** @since \
version 3.10.0 */ version 3.10.0 */
#else #else
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE #define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE
#endif #endif
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \ #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \
_Pragma("clang diagnostic ignored \"-Wformat-nonliteral\"") /** @since version 3.9.0 */ WINPR_DO_PRAGMA(clang diagnostic ignored "-Wformat-nonliteral") /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC /** @since version 3.3.0 */ /* not supported \ #define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC /** @since version 3.3.0 */ /* not supported \
_Pragma("clang diagnostic ignored \"-Wmismatched-dealloc\"") */ WINPR_DO_PRAGMA(clang diagnostic ignored "-Wmismatched-dealloc") */
#define WINPR_PRAGMA_DIAG_POP _Pragma("clang diagnostic pop") #define WINPR_PRAGMA_DIAG_POP WINPR_DO_PRAGMA(clang diagnostic pop)
#define WINPR_PRAGMA_UNROLL_LOOP \ #define WINPR_PRAGMA_UNROLL_LOOP \
_Pragma("clang loop vectorize_width(8) interleave_count(8)") /** @since version 3.6.0 */ _Pragma("clang loop vectorize_width(8) interleave_count(8)") /** @since version 3.6.0 \
*/
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define WINPR_PRAGMA_DIAG_PUSH _Pragma("GCC diagnostic push") #define WINPR_PRAGMA_DIAG_PUSH WINPR_DO_PRAGMA(GCC diagnostic push)
#define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \ #define WINPR_PRAGMA_DIAG_IGNORED_OVERLENGTH_STRINGS \
_Pragma("GCC diagnostic ignored \"-Woverlength-strings\"") /** @since version 3.9.0 */ WINPR_DO_PRAGMA(GCC diagnostic ignored "-Woverlength-strings") /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS \ #define WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS \
_Pragma("GCC diagnostic ignored \"-Wdiscarded-qualifiers\"") /** @since version 3.9.0 */ WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wdiscarded-qualifiers") /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC _Pragma("GCC diagnostic ignored \"-Wpedantic\"") #define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wpedantic")
#define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \ #define WINPR_PRAGMA_DIAG_IGNORED_MISSING_PROTOTYPES \
_Pragma("GCC diagnostic ignored \"-Wmissing-prototypes\"") WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wmissing-prototypes")
#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES \ #define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES \
_Pragma("GCC diagnostic ignored \"-Wstrict-prototypes\"") WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wstrict-prototypes")
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO /* not supported _Pragma("GCC diagnostic \ #define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO /* not supported WINPR_DO_PRAGMA(GCC \
ignored \"-Wreserved-id-macro\"") */ diagnostic ignored "-Wreserved-id-macro") \
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO _Pragma("GCC diagnostic ignored \"-Wunused-macros\"") */
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO \
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wunused-macros")
#define WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS \
WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wunknown-pragmas") /** @since version 3.10.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER #define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
/* not supported _Pragma("GCC diagnostic ignored \"-Wreserved-identifier\"") */ /* not supported WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wreserved-identifier") */
#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST /* not supported _Pragma("GCC diagnostic \ #define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST /* not supported WINPR_DO_PRAGMA(GCC diagnostic \
ignored \ ignored \
\"-Watomic-implicit-seq-cst\"") */ "-Watomic-implicit-seq-cst") */
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR \ #define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR \
_Pragma("GCC diagnostic ignored \"-Wunused-const-variable\"") WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wunused-const-variable")
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \ #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_SECURITY \
_Pragma("GCC diagnostic ignored \"-Wformat-security\"") WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wformat-security")
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE /* not supported #define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_CONSTANT_OUT_OF_RANGE_COMPARE /* not supported
_Pragma("GCC diagnostic ignored \"-Wtautological-constant-out-of-range-compare\"") */ /** @since version 3.9.0 */ WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare") */ /** @since version 3.9.0 */
#define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE /* not supported #define WINPR_PRAGMA_DIAG_TAUTOLOGICAL_VALUE_RANGE_COMPARE /* not supported
_Pragma("GCC diagnostic ignored \"-Wtautological-value-range-compare\"") */ /** @since version 3.10.0 */ WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wtautological-value-range-compare") */ /** @since version 3.10.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \ #define WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL \
_Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") /** @since version 3.9.0 */ WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wformat-nonliteral") /** @since version 3.9.0 */
#if __GNUC__ >= 11 #if __GNUC__ >= 11
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC \ #define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC \
_Pragma("GCC diagnostic ignored \"-Wmismatched-dealloc\"") /** @since version 3.3.0 */ WINPR_DO_PRAGMA(GCC diagnostic ignored "-Wmismatched-dealloc") /** @since version 3.3.0 */
#else #else
#define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC #define WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
#endif #endif
#define WINPR_PRAGMA_DIAG_POP _Pragma("GCC diagnostic pop") #define WINPR_PRAGMA_DIAG_POP WINPR_DO_PRAGMA(GCC diagnostic pop)
#define WINPR_PRAGMA_UNROLL_LOOP \ #define WINPR_PRAGMA_UNROLL_LOOP \
_Pragma("GCC unroll 8") _Pragma("GCC ivdep") /** @since version 3.6.0 */ WINPR_DO_PRAGMA(GCC unroll 8) WINPR_DO_PRAGMA(GCC ivdep) /** @since version 3.6.0 */
#else #else
#define WINPR_PRAGMA_DIAG_PUSH #define WINPR_PRAGMA_DIAG_PUSH
#define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC #define WINPR_PRAGMA_DIAG_IGNORED_PEDANTIC
@ -156,6 +174,7 @@
#define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES #define WINPR_PRAGMA_DIAG_IGNORED_STRICT_PROTOTYPES
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO #define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO #define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_MACRO
#define WINPR_PRAGMA_DIAG_IGNORED_UNKNOWN_PRAGMAS /** @since version 3.10.0 */
#define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER #define WINPR_PRAGMA_DIAG_IGNORED_RESERVED_IDENTIFIER
#define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST #define WINPR_PRAGMA_DIAG_IGNORED_ATOMIC_SEQ_CST
#define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR #define WINPR_PRAGMA_DIAG_IGNORED_UNUSED_CONST_VAR
@ -170,7 +189,7 @@
#if defined(MSVC) #if defined(MSVC)
#undef WINPR_PRAGMA_UNROLL_LOOP #undef WINPR_PRAGMA_UNROLL_LOOP
#define WINPR_PRAGMA_UNROLL_LOOP _Pragma("loop ( ivdep )") /** @since version 3.6.0 */ #define WINPR_PRAGMA_UNROLL_LOOP WINPR_DO_PRAGMA(loop(ivdep)) /** @since version 3.6.0 */
#endif #endif
WINPR_PRAGMA_DIAG_PUSH WINPR_PRAGMA_DIAG_PUSH

View File

@ -48,9 +48,8 @@ int TestFormatSpecifiers(int argc, char* argv[])
UINT8 arg = 0xFE; UINT8 arg = 0xFE;
const char* chk = "u8:254 o8:376 x8:fe X8:FE"; const char* chk = "u8:254 o8:376 x8:fe X8:FE";
(void)(void)sprintf_s(fmt, sizeof(fmt), (void)sprintf_s(fmt, sizeof(fmt), "u8:%" PRIu8 " o8:%" PRIo8 " x8:%" PRIx8 " X8:%" PRIX8 "",
"u8:%" PRIu8 " o8:%" PRIo8 " x8:%" PRIx8 " X8:%" PRIX8 "", arg, arg, arg, arg, arg, arg);
arg, arg);
if (strcmp(fmt, chk) != 0) if (strcmp(fmt, chk) != 0)
{ {

View File

@ -475,6 +475,8 @@ static const EVP_CIPHER* winpr_openssl_get_evp_cipher(WINPR_CIPHER_TYPE cipher)
case WINPR_CIPHER_BLOWFISH_CTR: case WINPR_CIPHER_BLOWFISH_CTR:
evp = EVP_get_cipherbyname("blowfish-ctr"); evp = EVP_get_cipherbyname("blowfish-ctr");
break; break;
default:
break;
} }
return evp; return evp;

View File

@ -1100,7 +1100,7 @@ WINSCARDAPI char* WINAPI SCardGetReaderStateString(DWORD dwReaderState)
return buffer; return buffer;
} }
#define WINSCARD_LOAD_PROC(_name, ...) \ #define WINSCARD_LOAD_PROC(_name) \
do \ do \
{ \ { \
WINPR_PRAGMA_DIAG_PUSH \ WINPR_PRAGMA_DIAG_PUSH \

View File

@ -48,7 +48,7 @@
#include "../log.h" #include "../log.h"
#define TAG WINPR_TAG("smartcard") #define TAG WINPR_TAG("smartcard")
#define WINSCARD_LOAD_PROC_EX(module, pcsc, _fname, _name, ...) \ #define WINSCARD_LOAD_PROC_EX(module, pcsc, _fname, _name) \
do \ do \
{ \ { \
WINPR_PRAGMA_DIAG_PUSH \ WINPR_PRAGMA_DIAG_PUSH \
@ -57,8 +57,7 @@
WINPR_PRAGMA_DIAG_POP \ WINPR_PRAGMA_DIAG_POP \
} while (0) } while (0)
#define WINSCARD_LOAD_PROC(module, pcsc, _name, ...) \ #define WINSCARD_LOAD_PROC(module, pcsc, _name) WINSCARD_LOAD_PROC_EX(module, pcsc, _name, _name)
WINSCARD_LOAD_PROC_EX(module, pcsc, _name, _name, ##__VA_ARGS__)
/** /**
* PC/SC transactions: * PC/SC transactions:

View File

@ -78,7 +78,7 @@ static VOID CALLBACK Timer2APCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dw
static DWORD /*WINAPI*/ closeHandleTest(LPVOID lpThreadParameter) static DWORD /*WINAPI*/ closeHandleTest(LPVOID lpThreadParameter)
{ {
LARGE_INTEGER dueTime; LARGE_INTEGER dueTime = { 0 };
UncleanCloseData* data = (UncleanCloseData*)lpThreadParameter; UncleanCloseData* data = (UncleanCloseData*)lpThreadParameter;
data->endTest = FALSE; data->endTest = FALSE;

View File

@ -7,7 +7,7 @@ int TestSynchWaitableTimer(int argc, char* argv[])
DWORD status = 0; DWORD status = 0;
HANDLE timer = NULL; HANDLE timer = NULL;
LONG period = 0; LONG period = 0;
LARGE_INTEGER due; LARGE_INTEGER due = { 0 };
int result = -1; int result = -1;
WINPR_UNUSED(argc); WINPR_UNUSED(argc);
WINPR_UNUSED(argv); WINPR_UNUSED(argv);

View File

@ -38,7 +38,7 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[])
DWORD rc = 0; DWORD rc = 0;
HANDLE hTimer = NULL; HANDLE hTimer = NULL;
BOOL bSuccess = 0; BOOL bSuccess = 0;
LARGE_INTEGER due; LARGE_INTEGER due = { 0 };
APC_DATA apcData = { 0 }; APC_DATA apcData = { 0 };
WINPR_UNUSED(argc); WINPR_UNUSED(argc);
WINPR_UNUSED(argv); WINPR_UNUSED(argv);

View File

@ -1001,8 +1001,8 @@ BOOL IsProcessorFeaturePresent(DWORD ProcessorFeature)
DWORD GetTickCountPrecise(void) DWORD GetTickCountPrecise(void)
{ {
#ifdef _WIN32 #ifdef _WIN32
LARGE_INTEGER freq; LARGE_INTEGER freq = { 0 };
LARGE_INTEGER current; LARGE_INTEGER current = { 0 };
QueryPerformanceFrequency(&freq); QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&current); QueryPerformanceCounter(&current);
return (DWORD)(current.QuadPart * 1000LL / freq.QuadPart); return (DWORD)(current.QuadPart * 1000LL / freq.QuadPart);

View File

@ -553,7 +553,7 @@ exit:
set_event(thread); set_event(thread);
signal_thread_ready(thread); (void)signal_thread_ready(thread);
if (thread->detached || !thread->started) if (thread->detached || !thread->started)
cleanup_handle(thread); cleanup_handle(thread);

View File

@ -81,7 +81,7 @@ static void append_timezone(const char* dir, const char* name)
tzset(); tzset();
const time_t t = time(NULL); const time_t t = time(NULL);
struct tm lt = { 0 }; struct tm lt = { 0 };
localtime_r(&t, &lt); (void)localtime_r(&t, &lt);
append(tz, lt.tm_zone); append(tz, lt.tm_zone);
if (oldtz) if (oldtz)
{ {

View File

@ -393,7 +393,7 @@ static struct tm next_day(const struct tm* start)
cur.tm_isdst = -1; cur.tm_isdst = -1;
cur.tm_mday++; cur.tm_mday++;
const time_t t = mktime(&cur); const time_t t = mktime(&cur);
localtime_r(&t, &cur); (void)localtime_r(&t, &cur);
return cur; return cur;
} }
@ -405,7 +405,7 @@ static struct tm adjust_time(const struct tm* start, int hour, int minute)
cur.tm_sec = 0; cur.tm_sec = 0;
cur.tm_isdst = -1; cur.tm_isdst = -1;
const time_t t = mktime(&cur); const time_t t = mktime(&cur);
localtime_r(&t, &cur); (void)localtime_r(&t, &cur);
return cur; return cur;
} }
@ -426,7 +426,7 @@ static WORD get_transition_weekday_occurrence(const SYSTEMTIME* st)
next.tm_mday++; next.tm_mday++;
struct tm cur = { 0 }; struct tm cur = { 0 };
localtime_r(&t, &cur); (void)localtime_r(&t, &cur);
if (cur.tm_mon + 1 != st->wMonth) if (cur.tm_mon + 1 != st->wMonth)
break; break;

View File

@ -112,8 +112,12 @@ static BOOL WLog_JournaldAppender_WriteMessage(wLog* log, wLogAppender* appender
WLog_Layout_GetMessagePrefix(log, appender->Layout, message); WLog_Layout_GetMessagePrefix(log, appender->Layout, message);
if (message->Level != WLOG_OFF) if (message->Level != WLOG_OFF)
(void)fprintf(journaldAppender->stream, formatStr, message->PrefixString, {
message->TextString); WINPR_PRAGMA_DIAG_PUSH
WINPR_PRAGMA_DIAG_IGNORED_FORMAT_NONLITERAL(void)
fprintf(journaldAppender->stream, formatStr, message->PrefixString, message->TextString);
WINPR_PRAGMA_DIAG_POP
}
return TRUE; return TRUE;
} }