Merge pull request #3739 from firewave/cppcheck-style-xxx

fixed some `unreadVariable` Cppcheck warnings
This commit is contained in:
matt335672
2026-03-04 14:25:59 +00:00
committed by GitHub
23 changed files with 57 additions and 83 deletions
+1 -1
View File
@@ -1015,7 +1015,7 @@ internal_log_message(const enum logLevels lvl,
char buff[LOG_BUFFER_SIZE + 43]; /* 31 ("[2022-10-07T19:58:33.065+0900] ") + 8 (log level) + 4 (space+cr+lf+\0) */
int len = 0;
enum logReturns rv = LOG_STARTUP_OK;
int writereply = 0;
int writereply;
if (g_staticLogConfig == NULL)
{
+1 -1
View File
@@ -2060,7 +2060,7 @@ g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, int wcount,
#else
struct pollfd pollfd[MAX_HANDLES];
int sck;
int i = 0;
int i;
unsigned int j = 0;
int rv = 1;
+1 -1
View File
@@ -777,7 +777,7 @@ g_strtrim(char *str, int trim_flags)
char *
g_strnjoin(char *dest, int dest_len, const char *joiner, const char *src[], int src_len)
{
int len = 0;
int len;
int joiner_len;
int i = 0;
int dest_remaining;
+4 -5
View File
@@ -308,11 +308,11 @@ trans_send_waiting(struct trans *self, int block)
int
trans_check_wait_objs(struct trans *self)
{
tbus in_sck = (tbus) 0;
tbus in_sck;
struct trans *in_trans = (struct trans *) NULL;
int read_bytes = 0;
unsigned int to_read = 0;
unsigned int read_so_far = 0;
int read_bytes;
unsigned int to_read;
unsigned int read_so_far;
int rv = 0;
enum xrdp_source cur_source;
@@ -616,7 +616,6 @@ trans_write_copy_s(struct trans *self, struct stream *out_s)
return 1;
}
out_data = out_s->data;
sent = 0;
size = (int) (out_s->end - out_s->data);
if (self->wait_s == 0)
{
+1 -1
View File
@@ -323,7 +323,7 @@ libxrdp_send_palette(struct xrdp_session *session, int *palette)
{
int rv;
int i = 0;
int color = 0;
int color;
struct stream *s = (struct stream *)NULL;
if (session->client_info->bpp > 8)
+2 -5
View File
@@ -729,17 +729,14 @@ xrdp_caps_process_frame_ack(struct xrdp_rdp *self, struct stream *s, int len)
static int
xrdp_caps_process_surface_cmds(struct xrdp_rdp *self, struct stream *s, int len)
{
#ifdef USE_DEVEL_LOGGING
int cmdFlags;
#ifndef USE_DEVEL_LOGGING
/* TODO: remove UNUSED_VAR once the `cmdFlags` variable is used for more than
logging in debug mode */
UNUSED_VAR(cmdFlags);
#endif
LOG_DEVEL(LOG_LEVEL_TRACE, "xrdp_caps_process_surface_cmds:");
in_uint32_le(s, cmdFlags);
in_uint8s(s, 4); /* reserved */
LOG_DEVEL(LOG_LEVEL_TRACE, " cmdFlags 0x%08x", cmdFlags);
#endif
return 0;
}
+7 -7
View File
@@ -843,13 +843,13 @@ xrdp_mcs_out_gcc_data(struct xrdp_sec *self)
int gcc_size;
char *gcc_size_ptr;
char *ud_ptr;
int header_length = 0;
int server_cert_len = 0;
int public_key_blob_len = 0;
int key_len = 0;
int bit_len = 0;
int data_len = 0;
int modulus_len = 0;
int header_length;
int server_cert_len;
int public_key_blob_len;
int key_len;
int bit_len;
int data_len;
int modulus_len;
num_channels = self->mcs_layer->channel_list->count;
num_channels_even = num_channels + (num_channels & 1);
+2 -4
View File
@@ -560,10 +560,10 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
tui32 data_end;
tui8 byte_val;
crc = 0;
lom = 0;
ctr = 0;
opb_index = 0;
bits_left = 8;
copy_offset = 0;
hash_table = enc->hash_table;
hbuf_start = enc->historyBuffer;
outputBuffer = enc->outputBuffer;
@@ -588,8 +588,6 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
/* point to start of data to be compressed */
historyPointer = &(enc->historyBuffer[historyOffset]);
ctr = copy_offset = lom = 0;
/* if we are at start of history buffer, do not attempt to compress */
/* first 2 bytes, because minimum LoM is 3 */
if (historyOffset == 0)
+6 -6
View File
@@ -450,7 +450,7 @@ xrdp_order_pack_small_or_tiny(struct xrdp_orders *self,
{
int move_up_count = 0;
int index = 0;
int size = 0;
int size;
int keep_looking = 1;
move_up_count = 0;
@@ -2237,9 +2237,9 @@ xrdp_orders_send_raw_bitmap(struct xrdp_orders *self,
int len = 0;
int bufsize = 0;
int Bpp = 0;
int i = 0;
int j = 0;
int pixel = 0;
int i;
int j;
int pixel;
int e = 0;
int max_order_size;
struct xrdp_client_info *ci;
@@ -2664,8 +2664,8 @@ xrdp_orders_send_raw_bitmap2(struct xrdp_orders *self,
int bufsize = 0;
int Bpp = 0;
int i = 0;
int j = 0;
int pixel = 0;
int j;
int pixel;
int e = 0;
int max_order_size;
struct xrdp_client_info *ci;
+3 -3
View File
@@ -48,7 +48,7 @@ xrdp_rdp_read_config(const char *xrdp_ini, struct xrdp_client_info *client_info)
char *value = NULL;
int pos;
char *tmp = NULL;
int tmp_length = 0;
int tmp_length;
client_info->xrdp_keyboard_overrides.type = -1;
client_info->xrdp_keyboard_overrides.subtype = -1;
@@ -461,10 +461,10 @@ xrdp_rdp_init_data(struct xrdp_rdp *self, struct stream *s)
int
xrdp_rdp_recv(struct xrdp_rdp *self, struct stream *s, int *code)
{
int error = 0;
int error;
int len = 0;
int pdu_code = 0;
int chan = 0;
int chan;
const tui8 *header;
+1 -1
View File
@@ -2237,7 +2237,7 @@ xrdp_sec_incoming(struct xrdp_sec *self)
struct list *items = NULL;
struct list *values = NULL;
struct xrdp_iso *iso;
int index = 0;
int index;
char *item = NULL;
char *value = NULL;
char key_file[256];
+3 -5
View File
@@ -1615,7 +1615,7 @@ devredir_file_create(struct state_create *fusep, tui32 device_id,
{
tui32 DesiredAccess;
tui32 CreateOptions;
tui32 FileAttributes = 0;
tui32 FileAttributes;
tui32 CreateDisposition;
int rval = -1;
IRP *irp;
@@ -1813,14 +1813,13 @@ devredir_file_read(struct state_read *fusep, tui32 DeviceId, tui32 FileId,
tui32 Length, tui64 Offset)
{
struct stream *s;
IRP *irp;
IRP *new_irp;
int bytes;
xstream_new(s, 1024);
/* Check we've got an open IRP for this file already */
if ((irp = devredir_irp_find_by_fileid(FileId)) == NULL)
if (devredir_irp_find_by_fileid(FileId) == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "no IRP found with FileId = %d", FileId);
xfuse_devredir_cb_read_file(fusep, STATUS_UNSUCCESSFUL, NULL, 0);
@@ -1870,7 +1869,6 @@ devredir_file_write(struct state_write *fusep, tui32 DeviceId, tui32 FileId,
const char *buf, int Length, tui64 Offset)
{
struct stream *s;
IRP *irp;
IRP *new_irp;
int bytes;
@@ -1879,7 +1877,7 @@ devredir_file_write(struct state_write *fusep, tui32 DeviceId, tui32 FileId,
xstream_new(s, 1024 + Length);
if ((irp = devredir_irp_find_by_fileid(FileId)) == NULL)
if (devredir_irp_find_by_fileid(FileId) == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "no IRP found with FileId = %d", FileId);
xfuse_devredir_cb_write_file(fusep, STATUS_UNSUCCESSFUL, 0, 0);
+14 -28
View File
@@ -975,11 +975,10 @@ scard_send_ReleaseContext(IRP *irp, char *context, int context_bytes)
{
/* see [MS-RDPESC] 3.1.4.2 */
SMARTCARD *sc;
struct stream *s;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1026,11 +1025,10 @@ scard_send_IsContextValid(IRP *irp, char *context, int context_bytes)
{
/* see [MS-RDPESC] 3.1.4.3 */
SMARTCARD *sc;
struct stream *s;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1138,7 +1136,6 @@ scard_send_ListReaders(IRP *irp, char *context, int context_bytes,
*
*/
SMARTCARD *sc;
struct stream *s;
int bytes;
int bytes_groups = 0; // Length of NDR for groups + 2 terminators
@@ -1146,7 +1143,7 @@ scard_send_ListReaders(IRP *irp, char *context, int context_bytes,
int groups_len = 0; // strlen(groups)
tui32 ioctl;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1357,14 +1354,13 @@ scard_send_GetStatusChange(IRP *irp, char *context, int context_bytes,
* ?? String names pointed to in the above array.
*/
SMARTCARD *sc;
READER_STATE *rs;
struct stream *s;
tui32 ioctl;
int bytes;
unsigned int i;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1507,12 +1503,11 @@ scard_send_Connect(IRP *irp, char *context, int context_bytes,
* ?? Conformant Array pointed to by pbContext
*
*/
SMARTCARD *sc;
struct stream *s;
tui32 ioctl;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1586,11 +1581,10 @@ scard_send_Reconnect(IRP *irp, char *context, int context_bytes,
/* see [MS-RDPESC] 2.2.2.15 */
/* see [MS-RDPESC] 3.1.4.36 */
SMARTCARD *sc;
struct stream *s;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1655,11 +1649,10 @@ scard_send_BeginTransaction(IRP *irp, char *context, int context_bytes,
{
/* see [MS-RDPESC] 4.9 */
SMARTCARD *sc;
struct stream *s;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1721,11 +1714,10 @@ scard_send_EndTransaction(IRP *irp, char *context, int context_bytes,
{
/* see [MS-RDPESC] 3.1.4.32 */
SMARTCARD *sc;
struct stream *s;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1787,12 +1779,11 @@ scard_send_Status(IRP *irp, int wide, char *context, int context_bytes,
{
/* see [MS-RDPESC] 2.2.2.18 */
SMARTCARD *sc;
struct stream *s;
int bytes;
tui32 ioctl;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1872,11 +1863,10 @@ scard_send_Disconnect(IRP *irp, char *context, int context_bytes,
{
/* see [MS-RDPESC] 3.1.4.30 */
SMARTCARD *sc;
struct stream *s;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return;
@@ -1939,12 +1929,11 @@ scard_send_Transmit(IRP *irp, char *context, int context_bytes,
{
/* see [MS-RDPESC] 2.2.2.19 */
SMARTCARD *sc;
struct stream *s;
int bytes;
int val;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return 1;
@@ -2127,12 +2116,11 @@ scard_send_Control(IRP *irp, char *context, int context_bytes,
{
/* see [MS-RDPESC] 2.2.2.19 */
SMARTCARD *sc;
struct stream *s;
int bytes;
int val;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return 1;
@@ -2201,11 +2189,10 @@ scard_send_Cancel(IRP *irp, char *context, int context_bytes)
{
/* see [MS-RDPESC] 3.1.4.27 */
SMARTCARD *sc;
struct stream *s;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return 1;
@@ -2253,11 +2240,10 @@ scard_send_GetAttrib(IRP *irp, char *card, int card_bytes, READER_STATE *rs)
{
/* see [MS-RDPESC] 2.2.2.21 */
SMARTCARD *sc;
struct stream *s;
int bytes;
if ((sc = smartcards[irp->scard_index]) == NULL)
if (smartcards[irp->scard_index] == NULL)
{
LOG_DEVEL(LOG_LEVEL_ERROR, "smartcards[%d] is NULL", irp->scard_index);
return 1;
-1
View File
@@ -488,7 +488,6 @@ scard_function_establish_context_return(void *user_data,
return 1;
}
con = uds_client->con;
lcontext = 0;
app_context = 0;
g_memset(context, 0, 16);
if (status == 0)
+1 -1
View File
@@ -100,7 +100,7 @@ static int
process_create_session_response(struct scp_list_item *sli)
{
struct session_item *s_item;
int display = -1;
int display;
struct guid guid;
enum scp_screate_status status;
+1 -1
View File
@@ -582,7 +582,7 @@ process_connect_session_request(struct scp_list_item *sli)
const char *client_ip;
const char *client_name;
unsigned int flags;
enum scp_sconnect_status status = E_SCP_SCONNECT_OK;
enum scp_sconnect_status status;
rv = scp_get_connect_session_request(sli->client_trans, &guid,
&client_ip, &client_name, &flags);
+1 -1
View File
@@ -348,7 +348,7 @@ close_ccp_trans(void)
static int
sesexec_main_loop(void)
{
int error = 0;
int error;
int robjs_count;
intptr_t robjs[MAX_ROBJS];
+1 -2
View File
@@ -36,7 +36,6 @@ static void
suite_test_libipm_calls_start(void)
{
int sck[2];
int istatus;
struct trans *t1 = NULL;
struct trans *t2 = NULL;
struct trans *t3 = NULL;
@@ -63,7 +62,7 @@ suite_test_libipm_calls_start(void)
const char *errstr = g_get_strerror();
LOG(LOG_LEVEL_ERROR, "Can't open /dev/zero [%s]", errstr);
}
else if ((istatus = g_sck_local_socketpair(sck)) < 0)
else if (g_sck_local_socketpair(sck) < 0)
{
const char *errstr = g_get_strerror();
LOG(LOG_LEVEL_ERROR, "Can't create test sockets [%s]", errstr);
+4 -4
View File
@@ -683,8 +683,8 @@ lib_mod_event(struct vnc *v, int msg, long param1, long param2,
static int
get_pixel_safe(char *data, int x, int y, int width, int height, int bpp)
{
int start = 0;
int shift = 0;
int start;
int shift;
if (x < 0)
{
@@ -753,8 +753,8 @@ static void
set_pixel_safe(char *data, int x, int y, int width, int height, int bpp,
int pixel)
{
int start = 0;
int shift = 0;
int start;
int shift;
if (x < 0)
{
+1 -1
View File
@@ -185,7 +185,7 @@ xrdp_bitmap_create_with_data(int width, int height,
void
xrdp_bitmap_delete(struct xrdp_bitmap *self)
{
int i = 0;
int i;
struct xrdp_mod_data *mod_data = (struct xrdp_mod_data *)NULL;
if (self == 0)
+1 -1
View File
@@ -2966,7 +2966,7 @@ static int
parse_chansrvport(const char *value, char *dest, int dest_size, int uid)
{
int rv = 0;
int dnum = 0;
int dnum;
if (value == NULL)
{
+1 -1
View File
@@ -223,7 +223,7 @@ xrdp_process_main_loop(struct xrdp_process *self)
int robjs_count;
int wobjs_count;
int cont;
int timeout = 0;
int timeout;
tbus robjs[32];
tbus wobjs[32];
tbus term_obj;
-2
View File
@@ -57,8 +57,6 @@ int
main(int argc, char **argv)
{
void *channel;
int written = 0;
int first_time = 1;
if (argc < 2)
{