[checks,return] fix various unchecked return values

This commit is contained in:
Armin Novak
2026-03-02 18:46:22 +01:00
parent 103e0907cc
commit b724ba546d
16 changed files with 50 additions and 30 deletions

View File

@@ -70,7 +70,8 @@ static BOOL delete_surface(const void* key, void* value, void* arg)
static void free_surfaces(RdpgfxClientContext* context, wHashTable* SurfaceTable) static void free_surfaces(RdpgfxClientContext* context, wHashTable* SurfaceTable)
{ {
HashTable_Foreach(SurfaceTable, delete_surface, context); if (!HashTable_Foreach(SurfaceTable, delete_surface, context))
WLog_WARN(TAG, "delete_surface failed");
} }
static UINT evict_cache_slots(RdpgfxClientContext* context, UINT16 MaxCacheSlots, void** CacheSlots) static UINT evict_cache_slots(RdpgfxClientContext* context, UINT16 MaxCacheSlots, void** CacheSlots)

View File

@@ -723,7 +723,8 @@ static UINT urbdrc_udevman_parse_addin_args(UDEVMAN* udevman, const ADDIN_ARGV*
const char* arg = args->argv[x]; const char* arg = args->argv[x];
if (strcmp(arg, "dbg") == 0) if (strcmp(arg, "dbg") == 0)
{ {
WLog_SetLogLevel(WLog_Get(TAG), WLOG_TRACE); if (!WLog_SetLogLevel(WLog_Get(TAG), WLOG_TRACE))
return ERROR_INTERNAL_ERROR;
} }
else if (_strnicmp(arg, "device:", 7) == 0) else if (_strnicmp(arg, "device:", 7) == 0)
{ {

View File

@@ -890,7 +890,8 @@ static UINT urbdrc_process_addin_args(URBDRC_PLUGIN* urbdrc, const ADDIN_ARGV* a
CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dbg") CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "dbg")
{ {
WLog_SetLogLevel(urbdrc->log, WLOG_TRACE); if (!WLog_SetLogLevel(urbdrc->log, WLOG_TRACE))
return ERROR_INTERNAL_ERROR;
} }
CommandLineSwitchCase(arg, "sys") CommandLineSwitchCase(arg, "sys")
{ {

View File

@@ -108,7 +108,8 @@ int main(int argc, char* argv[])
thread = freerdp_client_get_thread(context); thread = freerdp_client_get_thread(context);
(void)WaitForSingleObject(thread, INFINITE); (void)WaitForSingleObject(thread, INFINITE);
GetExitCodeThread(thread, &dwExitCode); if (!GetExitCodeThread(thread, &dwExitCode))
goto out;
rc = xf_exit_code_from_disconnect_reason(dwExitCode); rc = xf_exit_code_from_disconnect_reason(dwExitCode);
freerdp_client_stop(context); freerdp_client_stop(context);

View File

@@ -754,7 +754,11 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig
LogDynAndXClearWindow(xfc->log, xfc->display, window->handle); LogDynAndXClearWindow(xfc->log, xfc->display, window->handle);
xf_SetWindowTitleText(xfc, window->handle, name); xf_SetWindowTitleText(xfc, window->handle, name);
LogDynAndXMapWindow(xfc->log, xfc->display, window->handle); LogDynAndXMapWindow(xfc->log, xfc->display, window->handle);
xf_input_init(xfc, window->handle); if (!xf_input_init(xfc, window->handle))
{
xf_DestroyDesktopWindow(xfc, window);
return nullptr;
}
/* /*
* NOTE: This must be done here to handle reparenting the window, * NOTE: This must be done here to handle reparenting the window,

View File

@@ -549,15 +549,20 @@ static BOOL clear_clip_data_entries(WINPR_ATTR_UNUSED const void* key, void* val
return TRUE; return TRUE;
} }
static void clear_cdi_entries(CliprdrFileContext* file_context) WINPR_ATTR_NODISCARD
static UINT clear_cdi_entries(CliprdrFileContext* file_context)
{ {
UINT res = CHANNEL_RC_OK;
WINPR_ASSERT(file_context); WINPR_ASSERT(file_context);
HashTable_Lock(file_context->inode_table); HashTable_Lock(file_context->inode_table);
HashTable_Foreach(file_context->clip_data_table, clear_clip_data_entries, nullptr); if (!HashTable_Foreach(file_context->clip_data_table, clear_clip_data_entries, nullptr))
res = ERROR_INTERNAL_ERROR;
HashTable_Clear(file_context->clip_data_table); HashTable_Clear(file_context->clip_data_table);
HashTable_Unlock(file_context->inode_table); HashTable_Unlock(file_context->inode_table);
return res;
} }
static UINT prepare_clip_data_entry_with_id(CliprdrFileContext* file_context) static UINT prepare_clip_data_entry_with_id(CliprdrFileContext* file_context)
@@ -616,7 +621,7 @@ UINT cliprdr_file_context_notify_new_server_format_list(CliprdrFileContext* file
#if defined(WITH_FUSE) #if defined(WITH_FUSE)
clear_no_cdi_entry(file_context); clear_no_cdi_entry(file_context);
/* TODO: assign timeouts to old locks instead */ /* TODO: assign timeouts to old locks instead */
clear_cdi_entries(file_context); rc = clear_cdi_entries(file_context);
if (does_server_support_clipdata_locking(file_context)) if (does_server_support_clipdata_locking(file_context))
rc = prepare_clip_data_entry_with_id(file_context); rc = prepare_clip_data_entry_with_id(file_context);
@@ -634,7 +639,7 @@ UINT cliprdr_file_context_notify_new_client_format_list(CliprdrFileContext* file
#if defined(WITH_FUSE) #if defined(WITH_FUSE)
clear_no_cdi_entry(file_context); clear_no_cdi_entry(file_context);
/* TODO: assign timeouts to old locks instead */ /* TODO: assign timeouts to old locks instead */
clear_cdi_entries(file_context); return clear_cdi_entries(file_context);
#endif #endif
return CHANNEL_RC_OK; return CHANNEL_RC_OK;

View File

@@ -5606,7 +5606,6 @@ static int freerdp_client_settings_parse_command_line_arguments_int(
if (!isArgsFrom) if (!isArgsFrom)
warn_credential_args(largs); warn_credential_args(largs);
CommandLineFindArgumentA(largs, "v");
arg = largs; arg = largs;
errno = 0; errno = 0;

View File

@@ -663,9 +663,10 @@ static BOOL vgids_read_do_fkt(void* data, size_t index, va_list ap)
return TRUE; return TRUE;
} }
static void vgids_read_do(vgidsContext* context, UINT16 efID, UINT16 doID) WINPR_ATTR_NODISCARD
static BOOL vgids_read_do(vgidsContext* context, UINT16 efID, UINT16 doID)
{ {
ArrayList_ForEach(context->files, vgids_read_do_fkt, context, efID, doID); return ArrayList_ForEach(context->files, vgids_read_do_fkt, context, efID, doID);
} }
static void vgids_reset_context_response(vgidsContext* context) static void vgids_reset_context_response(vgidsContext* context)
@@ -897,7 +898,8 @@ static BOOL vgids_ins_getdata(vgidsContext* context, wStream* s, BYTE** response
} }
Stream_Read_UINT16_BE(s, doId); Stream_Read_UINT16_BE(s, doId);
vgids_read_do(context, fileId, doId); if (!vgids_read_do(context, fileId, doId))
return FALSE;
break; break;
} }
case 0xA: case 0xA:

View File

@@ -151,12 +151,15 @@ static BOOL start_irp_thread(pf_channel_client_context* scard,
work = CreateThreadpoolWork(irp_thread, arg, nullptr); work = CreateThreadpoolWork(irp_thread, arg, nullptr);
if (!work) if (!work)
goto fail; goto fail;
ArrayList_Append(scard->workObjects, work); if (!ArrayList_Append(scard->workObjects, work))
goto fail;
SubmitThreadpoolWork(work); SubmitThreadpoolWork(work);
return TRUE; return TRUE;
fail: fail:
if (work)
CloseThreadpoolWork(work);
if (arg) if (arg)
queue_free(arg->e); queue_free(arg->e);
free(arg); free(arg);

View File

@@ -483,7 +483,7 @@ static BOOL pf_modules_print_ArrayList_ForEachFkt(void* data, size_t index, va_l
return TRUE; return TRUE;
} }
void pf_modules_list_loaded_plugins(proxyModule* module) BOOL pf_modules_list_loaded_plugins(proxyModule* module)
{ {
size_t count = 0; size_t count = 0;
@@ -495,7 +495,7 @@ void pf_modules_list_loaded_plugins(proxyModule* module)
if (count > 0) if (count > 0)
WLog_INFO(TAG, "Loaded plugins:"); WLog_INFO(TAG, "Loaded plugins:");
ArrayList_ForEach(module->plugins, pf_modules_print_ArrayList_ForEachFkt); return ArrayList_ForEach(module->plugins, pf_modules_print_ArrayList_ForEachFkt);
} }
WINPR_ATTR_NODISCARD WINPR_ATTR_NODISCARD

View File

@@ -970,7 +970,9 @@ proxyServer* pf_server_new(const proxyConfig* config)
goto out; goto out;
} }
pf_modules_list_loaded_plugins(server->module); if (!pf_modules_list_loaded_plugins(server->module))
goto out;
if (!are_all_required_modules_loaded(server->module, server->config)) if (!are_all_required_modules_loaded(server->module, server->config))
goto out; goto out;

View File

@@ -90,7 +90,7 @@ extern "C"
WINPR_ATTR_NODISCARD BOOL pf_modules_is_plugin_loaded(proxyModule* module, WINPR_ATTR_NODISCARD BOOL pf_modules_is_plugin_loaded(proxyModule* module,
const char* plugin_name); const char* plugin_name);
void pf_modules_list_loaded_plugins(proxyModule* module); WINPR_ATTR_NODISCARD BOOL pf_modules_list_loaded_plugins(proxyModule* module);
WINPR_ATTR_NODISCARD BOOL pf_modules_run_filter(proxyModule* module, PF_FILTER_TYPE type, WINPR_ATTR_NODISCARD BOOL pf_modules_run_filter(proxyModule* module, PF_FILTER_TYPE type,
proxyData* pdata, void* param); proxyData* pdata, void* param);

View File

@@ -822,7 +822,6 @@ extern "C"
WINPR_API void MessagePipe_Free(wMessagePipe* pipe); WINPR_API void MessagePipe_Free(wMessagePipe* pipe);
WINPR_ATTR_MALLOC(MessagePipe_Free, 1) WINPR_ATTR_MALLOC(MessagePipe_Free, 1)
WINPR_ATTR_NODISCARD
WINPR_API wMessagePipe* MessagePipe_New(void); WINPR_API wMessagePipe* MessagePipe_New(void);
/* Publisher/Subscriber Pattern */ /* Publisher/Subscriber Pattern */

View File

@@ -653,7 +653,10 @@ static void* clipboard_synthesize_html_format(wClipboard* clipboard, UINT32 form
/* Check the BOM (Byte Order Mark) */ /* Check the BOM (Byte Order Mark) */
if ((pSrcData.cpb[0] == 0xFE) && (pSrcData.cpb[1] == 0xFF)) if ((pSrcData.cpb[0] == 0xFE) && (pSrcData.cpb[1] == 0xFF))
ByteSwapUnicode(pSrcData.pv, (SrcSize / 2)); {
if (!ByteSwapUnicode(pSrcData.pv, (SrcSize / 2)))
goto fail;
}
/* Check if we have WCHAR, convert to UTF-8 */ /* Check if we have WCHAR, convert to UTF-8 */
if ((pSrcData.cpb[0] == 0xFF) && (pSrcData.cpb[1] == 0xFE)) if ((pSrcData.cpb[0] == 0xFF) && (pSrcData.cpb[1] == 0xFE))

View File

@@ -104,7 +104,8 @@ static struct synthetic_file* make_synthetic_file(const WCHAR* local_name, const
{ {
const size_t len = _wcslen(file->remote_name); const size_t len = _wcslen(file->remote_name);
PathCchConvertStyleW(file->remote_name, len, PATH_STYLE_WINDOWS); if (S_OK != PathCchConvertStyleW(file->remote_name, len, PATH_STYLE_WINDOWS))
goto fail;
} }
file->dwFileAttributes = fd.dwFileAttributes; file->dwFileAttributes = fd.dwFileAttributes;

View File

@@ -18,6 +18,7 @@
*/ */
#include <winpr/config.h> #include <winpr/config.h>
#include <winpr/assert.h>
#include <winpr/crt.h> #include <winpr/crt.h>
#include <winpr/sysinfo.h> #include <winpr/sysinfo.h>
@@ -34,6 +35,7 @@
void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode) void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode)
{ {
WINPR_ASSERT(pipe);
MessageQueue_PostQuit(pipe->In, nExitCode); MessageQueue_PostQuit(pipe->In, nExitCode);
MessageQueue_PostQuit(pipe->Out, nExitCode); MessageQueue_PostQuit(pipe->Out, nExitCode);
} }
@@ -44,27 +46,23 @@ void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode)
wMessagePipe* MessagePipe_New(void) wMessagePipe* MessagePipe_New(void)
{ {
wMessagePipe* pipe = nullptr; wMessagePipe* pipe = (wMessagePipe*)calloc(1, sizeof(wMessagePipe));
pipe = (wMessagePipe*)malloc(sizeof(wMessagePipe));
if (!pipe) if (!pipe)
return nullptr; return nullptr;
pipe->In = MessageQueue_New(nullptr); pipe->In = MessageQueue_New(nullptr);
if (!pipe->In) if (!pipe->In)
goto error_in; goto fail;
pipe->Out = MessageQueue_New(nullptr); pipe->Out = MessageQueue_New(nullptr);
if (!pipe->Out) if (!pipe->Out)
goto error_out; goto fail;
return pipe; return pipe;
error_out: fail:
MessageQueue_Free(pipe->In); MessagePipe_Free(pipe);
error_in:
free(pipe);
return nullptr; return nullptr;
} }