[warnings] fix -Wunused-but-set-variable

This commit is contained in:
akallabeth
2025-03-06 00:34:18 +01:00
parent 5386c7b83c
commit 44d5461cd5
7 changed files with 42 additions and 97 deletions

View File

@@ -1495,15 +1495,10 @@ UINT rdpdr_try_send_device_list_announce_request(rdpdrPlugin* rdpdr)
static UINT dummy_irp_response(rdpdrPlugin* rdpdr, wStream* s)
{
wStream* output = NULL;
UINT32 DeviceId = 0;
UINT32 FileId = 0;
UINT32 CompletionId = 0;
WINPR_ASSERT(rdpdr);
WINPR_ASSERT(s);
output = StreamPool_Take(rdpdr->pool, 256); // RDPDR_DEVICE_IO_RESPONSE_LENGTH
wStream* output = StreamPool_Take(rdpdr->pool, 256); // RDPDR_DEVICE_IO_RESPONSE_LENGTH
if (!output)
{
WLog_Print(rdpdr->log, WLOG_ERROR, "Stream_New failed!");
@@ -1512,10 +1507,14 @@ static UINT dummy_irp_response(rdpdrPlugin* rdpdr, wStream* s)
Stream_SetPosition(s, 4); /* see "rdpdr_process_receive" */
Stream_Read_UINT32(s, DeviceId); /* DeviceId (4 bytes) */
Stream_Read_UINT32(s, FileId); /* FileId (4 bytes) */
Stream_Read_UINT32(s, CompletionId); /* CompletionId (4 bytes) */
const uint32_t DeviceId = Stream_Get_UINT32(s); /* DeviceId (4 bytes) */
const uint32_t FileId = Stream_Get_UINT32(s); /* FileId (4 bytes) */
const uint32_t CompletionId = Stream_Get_UINT32(s); /* CompletionId (4 bytes) */
WLog_Print(rdpdr->log, WLOG_ERROR,
"Dummy response {DeviceId=%" PRIu32 ", FileId=%" PRIu32 ", CompletionId=%" PRIu32
"}",
DeviceId, FileId, CompletionId);
if (!rdpdr_write_iocompletion_header(output, DeviceId, CompletionId, STATUS_UNSUCCESSFUL))
return CHANNEL_RC_NO_MEMORY;

View File

@@ -751,19 +751,9 @@ BOOL rdp_server_accept_client_control_pdu(rdpRdp* rdp, wStream* s)
BOOL rdp_server_accept_client_font_list_pdu(rdpRdp* rdp, wStream* s)
{
rdpSettings* settings = NULL;
freerdp_peer* peer = NULL;
WINPR_ASSERT(rdp);
WINPR_ASSERT(s);
settings = rdp->settings;
WINPR_ASSERT(settings);
WINPR_ASSERT(rdp->context);
peer = rdp->context->peer;
WINPR_ASSERT(peer);
if (!rdp_recv_client_font_list_pdu(s))
return FALSE;
rdp_finalize_set_flag(rdp, FINALIZE_CS_FONT_LIST_PDU);

View File

@@ -1678,12 +1678,8 @@ BOOL WINAPI FreeRDP_WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer,
}
else
{
rdpContext* context = NULL;
first = TRUE;
WINPR_ASSERT(channel->client);
context = channel->client->context;
WINPR_ASSERT(context);
while (Length > 0)
{
s = Stream_New(NULL, DVC_MAX_DATA_PDU_SIZE);

View File

@@ -559,12 +559,11 @@ static BOOL tf_peer_dump_rfx(freerdp_peer* client)
rdpUpdate* update = NULL;
rdpPcap* pcap_rfx = NULL;
pcap_record record = { 0 };
struct server_info* info = NULL;
WINPR_ASSERT(client);
WINPR_ASSERT(client->context);
info = client->ContextExtra;
struct server_info* info = client->ContextExtra;
WINPR_ASSERT(info);
s = Stream_New(NULL, 512);
@@ -798,7 +797,6 @@ static BOOL tf_peer_post_connect(freerdp_peer* client)
static BOOL tf_peer_activate(freerdp_peer* client)
{
testPeerContext* context = NULL;
struct server_info* info = NULL;
rdpSettings* settings = NULL;
WINPR_ASSERT(client);
@@ -809,7 +807,7 @@ static BOOL tf_peer_activate(freerdp_peer* client)
settings = client->context->settings;
WINPR_ASSERT(settings);
info = client->ContextExtra;
struct server_info* info = client->ContextExtra;
WINPR_ASSERT(info);
context->activated = TRUE;
@@ -1004,9 +1002,6 @@ static int hook_peer_write_pdu(rdpTransport* transport, wStream* s)
UINT64 ts = 0;
wStream* ls = NULL;
UINT64 last_ts = 0;
const struct server_info* info = NULL;
freerdp_peer* client = NULL;
testPeerContext* peerCtx = NULL;
size_t offset = 0;
UINT32 flags = 0;
rdpContext* context = transport_get_context(transport);
@@ -1014,16 +1009,13 @@ static int hook_peer_write_pdu(rdpTransport* transport, wStream* s)
WINPR_ASSERT(context);
WINPR_ASSERT(s);
client = context->peer;
freerdp_peer* client = context->peer;
WINPR_ASSERT(client);
peerCtx = (testPeerContext*)client->context;
testPeerContext* peerCtx = (testPeerContext*)client->context;
WINPR_ASSERT(peerCtx);
WINPR_ASSERT(peerCtx->io.WritePdu);
info = client->ContextExtra;
WINPR_ASSERT(info);
/* Let the client authenticate.
* After that is done, we stop the normal operation and send
* a previously recorded session PDU by PDU to the client.
@@ -1031,7 +1023,6 @@ static int hook_peer_write_pdu(rdpTransport* transport, wStream* s)
* This is fragile and the connecting client needs to use the same
* configuration as the one that recorded the session!
*/
WINPR_ASSERT(info);
CONNECTION_STATE state = freerdp_get_state(context);
if (state < CONNECTION_STATE_NEGO)
return peerCtx->io.WritePdu(transport, s);
@@ -1077,7 +1068,6 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg)
DWORD count = 0;
DWORD status = 0;
testPeerContext* context = NULL;
struct server_info* info = NULL;
rdpSettings* settings = NULL;
rdpInput* input = NULL;
rdpUpdate* update = NULL;
@@ -1085,7 +1075,7 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg)
WINPR_ASSERT(client);
info = client->ContextExtra;
struct server_info* info = client->ContextExtra;
WINPR_ASSERT(info);
if (!test_peer_init(client))
@@ -1273,14 +1263,13 @@ fail:
static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
{
HANDLE hThread = NULL;
struct server_info* info = NULL;
WINPR_UNUSED(instance);
WINPR_ASSERT(instance);
WINPR_ASSERT(client);
info = instance->info;
struct server_info* info = instance->info;
client->ContextExtra = info;
if (!(hThread = CreateThread(NULL, 0, test_peer_mainloop, (void*)client, 0, NULL)))

View File

@@ -119,16 +119,9 @@ static void pf_client_on_activated(void* ctx, WINPR_ATTR_UNUSED const ActivatedE
static BOOL pf_client_load_rdpsnd(pClientContext* pc)
{
rdpContext* context = (rdpContext*)pc;
pServerContext* ps = NULL;
const proxyConfig* config = NULL;
WINPR_ASSERT(pc);
WINPR_ASSERT(pc->pdata);
ps = pc->pdata->ps;
WINPR_ASSERT(ps);
config = pc->pdata->config;
WINPR_ASSERT(config);
/*
* if AudioOutput is enabled in proxy and client connected with rdpsnd, use proxy as rdpsnd
* backend. Otherwise, use sys:fake.
@@ -540,27 +533,16 @@ static BOOL sendQueuedChannelData(pClientContext* pc)
*/
static BOOL pf_client_post_connect(freerdp* instance)
{
rdpContext* context = NULL;
rdpSettings* settings = NULL;
rdpUpdate* update = NULL;
rdpContext* ps = NULL;
pClientContext* pc = NULL;
const proxyConfig* config = NULL;
WINPR_ASSERT(instance);
context = instance->context;
rdpContext* context = instance->context;
WINPR_ASSERT(context);
settings = context->settings;
WINPR_ASSERT(settings);
update = context->update;
rdpUpdate* update = context->update;
WINPR_ASSERT(update);
pc = (pClientContext*)context;
pClientContext* pc = (pClientContext*)context;
WINPR_ASSERT(pc);
WINPR_ASSERT(pc->pdata);
ps = (rdpContext*)pc->pdata->ps;
rdpContext* ps = (rdpContext*)pc->pdata->ps;
WINPR_ASSERT(ps);
config = pc->pdata->config;
WINPR_ASSERT(config);
if (!pf_modules_run_hook(pc->pdata->module, HOOK_TYPE_CLIENT_POST_CONNECT, pc->pdata, pc))
return FALSE;
@@ -568,7 +550,7 @@ static BOOL pf_client_post_connect(freerdp* instance)
if (!gdi_init(instance, PIXEL_FORMAT_BGRA32))
return FALSE;
WINPR_ASSERT(freerdp_settings_get_bool(settings, FreeRDP_SoftwareGdi));
WINPR_ASSERT(freerdp_settings_get_bool(context->settings, FreeRDP_SoftwareGdi));
pf_client_register_update_callbacks(update);
@@ -629,19 +611,14 @@ static void pf_client_post_disconnect(freerdp* instance)
static BOOL pf_client_redirect(freerdp* instance)
{
pClientContext* pc = NULL;
proxyData* pdata = NULL;
if (!instance)
return FALSE;
if (!instance->context)
return FALSE;
pc = (pClientContext*)instance->context;
pClientContext* pc = (pClientContext*)instance->context;
WINPR_ASSERT(pc);
pdata = pc->pdata;
WINPR_ASSERT(pdata);
#if defined(WITH_PROXY_EMULATE_SMARTCARD)
pf_channel_smartcard_client_reset(pc);

View File

@@ -403,24 +403,18 @@ static BOOL pf_server_receive_channel_data_hook(freerdp_peer* peer, UINT16 chann
const BYTE* data, size_t size, UINT32 flags,
size_t totalSize)
{
pServerContext* ps = NULL;
pClientContext* pc = NULL;
proxyData* pdata = NULL;
const proxyConfig* config = NULL;
const pServerStaticChannelContext* channel = NULL;
UINT64 channelId64 = channelId;
WINPR_ASSERT(peer);
ps = (pServerContext*)peer->context;
pServerContext* ps = (pServerContext*)peer->context;
WINPR_ASSERT(ps);
pdata = ps->pdata;
proxyData* pdata = ps->pdata;
WINPR_ASSERT(pdata);
pc = pdata->pc;
config = pdata->config;
WINPR_ASSERT(config);
pClientContext* pc = pdata->pc;
/*
* client side is not initialized yet, call original callback.
* this is probably a drdynvc message between peer and proxy server,
@@ -429,7 +423,8 @@ static BOOL pf_server_receive_channel_data_hook(freerdp_peer* peer, UINT16 chann
if (!pc)
goto original_cb;
channel = HashTable_GetItemValue(ps->channelsByFrontId, &channelId64);
const pServerStaticChannelContext* channel =
HashTable_GetItemValue(ps->channelsByFrontId, &channelId64);
if (!channel)
{
PROXY_LOG_ERR(TAG, ps, "channel id=%" PRIu64 " not registered here, dropping", channelId64);

View File

@@ -701,17 +701,11 @@ static BOOL shadow_client_suppress_output(rdpContext* context, BYTE allow, const
static BOOL shadow_client_activate(freerdp_peer* peer)
{
rdpSettings* settings = NULL;
rdpShadowClient* client = NULL;
WINPR_ASSERT(peer);
client = (rdpShadowClient*)peer->context;
rdpShadowClient* client = (rdpShadowClient*)peer->context;
WINPR_ASSERT(client);
settings = peer->context->settings;
WINPR_ASSERT(settings);
/* Resize client if necessary */
if (shadow_client_recalc_desktop_size(client))
return shadow_send_desktop_resize(client);
@@ -1398,7 +1392,6 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
}
else if (freerdp_settings_get_bool(settings, FreeRDP_GfxPlanar))
{
BOOL rc = 0;
const UINT32 w = cmd.right - cmd.left;
const UINT32 h = cmd.bottom - cmd.top;
const BYTE* src =
@@ -1409,8 +1402,10 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
return FALSE;
}
rc = freerdp_bitmap_planar_context_reset(encoder->planar, w, h);
WINPR_ASSERT(rc);
const BOOL rc = freerdp_bitmap_planar_context_reset(encoder->planar, w, h);
if (!rc)
return FALSE;
freerdp_planar_topdown_image(encoder->planar, TRUE);
cmd.data = freerdp_bitmap_compress_planar(encoder->planar, src, SrcFormat, w, h, nSrcStep,
@@ -1430,17 +1425,21 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE*
}
else
{
BOOL rc = 0;
const UINT32 w = cmd.right - cmd.left;
const UINT32 h = cmd.bottom - cmd.top;
const UINT32 length = w * 4 * h;
BYTE* data = malloc(length);
if (!data)
return FALSE;
WINPR_ASSERT(data);
rc = freerdp_image_copy_no_overlap(data, PIXEL_FORMAT_BGRA32, 0, 0, 0, w, h, pSrcData,
SrcFormat, nSrcStep, cmd.left, cmd.top, NULL, 0);
WINPR_ASSERT(rc);
BOOL rc = freerdp_image_copy_no_overlap(data, PIXEL_FORMAT_BGRA32, 0, 0, 0, w, h, pSrcData,
SrcFormat, nSrcStep, cmd.left, cmd.top, NULL, 0);
if (!rc)
{
free(data);
return FALSE;
}
cmd.data = data;
cmd.length = length;