diff --git a/common/log.c b/common/log.c index a48b4583..7200a08c 100644 --- a/common/log.c +++ b/common/log.c @@ -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) { diff --git a/common/os_calls.c b/common/os_calls.c index 2ad4c231..b6772cdf 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -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; diff --git a/common/string_calls.c b/common/string_calls.c index 99ec4b40..3a94e732 100644 --- a/common/string_calls.c +++ b/common/string_calls.c @@ -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; diff --git a/common/trans.c b/common/trans.c index cea9f9e8..312495c7 100644 --- a/common/trans.c +++ b/common/trans.c @@ -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) { diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index 8aea0df5..4cd48027 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -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) diff --git a/libxrdp/xrdp_caps.c b/libxrdp/xrdp_caps.c index b9851644..966773e3 100644 --- a/libxrdp/xrdp_caps.c +++ b/libxrdp/xrdp_caps.c @@ -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; } diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c index c9299d3e..84dd274d 100644 --- a/libxrdp/xrdp_mcs.c +++ b/libxrdp/xrdp_mcs.c @@ -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); diff --git a/libxrdp/xrdp_mppc_enc.c b/libxrdp/xrdp_mppc_enc.c index ccc4dff2..69e36e3e 100644 --- a/libxrdp/xrdp_mppc_enc.c +++ b/libxrdp/xrdp_mppc_enc.c @@ -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) diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 40b6bf53..7ec5bcce 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -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; diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index 4f2c6934..36e1d6e4 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -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; diff --git a/libxrdp/xrdp_sec.c b/libxrdp/xrdp_sec.c index 73b4846b..32ce7d74 100644 --- a/libxrdp/xrdp_sec.c +++ b/libxrdp/xrdp_sec.c @@ -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]; diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 85574e0d..ad68f4f5 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -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); diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c index 7dd1edd2..62f33f32 100644 --- a/sesman/chansrv/smartcard.c +++ b/sesman/chansrv/smartcard.c @@ -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; diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index 05841881..8a7b762b 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -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) diff --git a/sesman/eicp_process.c b/sesman/eicp_process.c index 708391c7..959fc33b 100644 --- a/sesman/eicp_process.c +++ b/sesman/eicp_process.c @@ -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; diff --git a/sesman/scp_process.c b/sesman/scp_process.c index c6ec60fc..a1f65f05 100644 --- a/sesman/scp_process.c +++ b/sesman/scp_process.c @@ -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); diff --git a/sesman/sesexec/sesexec.c b/sesman/sesexec/sesexec.c index 6fe12678..69843bc6 100644 --- a/sesman/sesexec/sesexec.c +++ b/sesman/sesexec/sesexec.c @@ -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]; diff --git a/tests/libipm/test_libipm_main.c b/tests/libipm/test_libipm_main.c index 3cf7233f..bfce2b62 100644 --- a/tests/libipm/test_libipm_main.c +++ b/tests/libipm/test_libipm_main.c @@ -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); diff --git a/vnc/vnc.c b/vnc/vnc.c index 56fdab9c..298e2d6c 100644 --- a/vnc/vnc.c +++ b/vnc/vnc.c @@ -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) { diff --git a/xrdp/xrdp_bitmap_common.c b/xrdp/xrdp_bitmap_common.c index 4e0025d3..01ae098f 100644 --- a/xrdp/xrdp_bitmap_common.c +++ b/xrdp/xrdp_bitmap_common.c @@ -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) diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index ab8628d4..025d5e9b 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -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) { diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c index ab8403ef..c1ac8b9f 100644 --- a/xrdp/xrdp_process.c +++ b/xrdp/xrdp_process.c @@ -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; diff --git a/xrdpapi/vrplayer.c b/xrdpapi/vrplayer.c index de20c303..0e2a6106 100644 --- a/xrdpapi/vrplayer.c +++ b/xrdpapi/vrplayer.c @@ -57,8 +57,6 @@ int main(int argc, char **argv) { void *channel; - int written = 0; - int first_time = 1; if (argc < 2) {