Skip to content

Commit 9d46ae7

Browse files
authored
Merge pull request #3658 from matt335672/remove_xrdp_process_casts
Code quality: Remove 'struct xrdp_process *' casts
2 parents 9e1a8d7 + c646002 commit 9d46ae7

File tree

8 files changed

+55
-59
lines changed

8 files changed

+55
-59
lines changed

libxrdp/libxrdp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
/******************************************************************************/
3535
struct xrdp_session *EXPORT_CC
36-
libxrdp_init(tbus id, struct trans *trans, const char *xrdp_ini)
36+
libxrdp_init(struct xrdp_process *id, struct trans *trans, const char *xrdp_ini)
3737
{
3838
struct xrdp_session *session;
3939

libxrdp/libxrdp.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,20 @@ struct xrdp_sec
135135
int is_security_header_present; /* boolean */
136136
};
137137

138+
struct xrdp_process;
139+
138140
struct xrdp_drdynvc
139141
{
140142
int chan_id;
141143
int status; /* see XRDP_DRDYNVC_STATUS_* */
142144
int flags;
143145
int pad0;
144-
int (*open_response)(intptr_t id, int chan_id, int creation_status);
145-
int (*close_response)(intptr_t id, int chan_id);
146-
int (*data_first)(intptr_t id, int chan_id, char *data, int bytes, int total_bytes);
147-
int (*data)(intptr_t id, int chan_id, char *data, int bytes);
146+
int (*open_response)(struct xrdp_process *id, int chan_id,
147+
int creation_status);
148+
int (*close_response)(struct xrdp_process *id, int chan_id);
149+
int (*data_first)(struct xrdp_process *id, int chan_id, char *data,
150+
int bytes, int total_bytes);
151+
int (*data)(struct xrdp_process *id, int chan_id, char *data, int bytes);
148152
};
149153

150154
/* channel */

libxrdp/libxrdpinc.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ struct xrdp_rect
6565

6666
struct xrdp_rdp;
6767
struct xrdp_orders;
68+
struct xrdp_process;
6869

6970
struct xrdp_session
7071
{
71-
tintptr id;
72+
struct xrdp_process *id;
7273
struct trans *trans;
73-
int (*callback)(intptr_t id, int msg, intptr_t param1, intptr_t param2,
74+
int (*callback)(struct xrdp_process *id, int msg,
75+
intptr_t param1, intptr_t param2,
7476
intptr_t param3, intptr_t param4);
7577
int check_for_app_input;
7678
struct xrdp_rdp *rdp;
@@ -86,10 +88,12 @@ struct xrdp_session
8688

8789
struct xrdp_drdynvc_procs
8890
{
89-
int (*open_response)(intptr_t id, int chan_id, int creation_status);
90-
int (*close_response)(intptr_t id, int chan_id);
91-
int (*data_first)(intptr_t id, int chan_id, char *data, int bytes, int total_bytes);
92-
int (*data)(intptr_t id, int chan_id, char *data, int bytes);
91+
int (*open_response)(struct xrdp_process *id, int chan_id,
92+
int creation_status);
93+
int (*close_response)(struct xrdp_process *id, int chan_id);
94+
int (*data_first)(struct xrdp_process *id, int chan_id,
95+
char *data, int bytes, int total_bytes);
96+
int (*data)(struct xrdp_process *id, int chan_id, char *data, int bytes);
9397
};
9498

9599
/* Defined in xrdp_client_info.h */
@@ -98,13 +102,14 @@ struct display_size_description;
98102
/***
99103
* Initialise the XRDP library
100104
*
101-
* @param id Channel ID (xrdp_process* as integer type)
105+
* @param proc XRDP instance to use with this library
102106
* @param trans Transport object to use for this instance
103107
* @param xrdp_ini Path to xrdp.ini config file, or NULL for default
104108
* @return an allocated xrdp_session object
105109
*/
106110
struct xrdp_session *
107-
libxrdp_init(tbus id, struct trans *trans, const char *xrdp_ini);
111+
libxrdp_init(struct xrdp_process *id,
112+
struct trans *trans, const char *xrdp_ini);
108113
int
109114
libxrdp_exit(struct xrdp_session *session);
110115
/**

xrdp/xrdp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ int
175175
xrdp_wm_pointer(struct xrdp_wm *self, char *data, char *mask, int x, int y,
176176
int bpp, int width, int height);
177177
int
178-
callback(intptr_t id, int msg, intptr_t param1, intptr_t param2,
178+
callback(struct xrdp_process *id, int msg, intptr_t param1, intptr_t param2,
179179
intptr_t param3, intptr_t param4);
180180
int
181181
xrdp_wm_delete_all_children(struct xrdp_wm *self);

xrdp/xrdp_egfx.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,8 @@ xrdp_egfx_process(struct xrdp_egfx *egfx, struct stream *s)
924924
/******************************************************************************/
925925
/* from client */
926926
static int
927-
xrdp_egfx_open_response(intptr_t id, int chan_id, int creation_status)
927+
xrdp_egfx_open_response(struct xrdp_process *id, int chan_id,
928+
int creation_status)
928929
{
929930
LOG(LOG_LEVEL_TRACE, "xrdp_egfx_open_response:");
930931
return 0;
@@ -933,15 +934,13 @@ xrdp_egfx_open_response(intptr_t id, int chan_id, int creation_status)
933934
/******************************************************************************/
934935
/* from client */
935936
static int
936-
xrdp_egfx_close_response(intptr_t id, int chan_id)
937+
xrdp_egfx_close_response(struct xrdp_process *id, int chan_id)
937938
{
938-
struct xrdp_process *process;
939939
struct xrdp_mm *mm;
940940

941941
LOG(LOG_LEVEL_TRACE, "xrdp_egfx_close_response:");
942942

943-
process = (struct xrdp_process *) id;
944-
mm = process->wm->mm;
943+
mm = id->wm->mm;
945944

946945
if (mm->resize_queue == 0 || mm->resize_queue->count <= 0)
947946
{
@@ -959,16 +958,14 @@ xrdp_egfx_close_response(intptr_t id, int chan_id)
959958
/******************************************************************************/
960959
/* from client */
961960
static int
962-
xrdp_egfx_data_first(intptr_t id, int chan_id, char *data, int bytes,
963-
int total_bytes)
961+
xrdp_egfx_data_first(struct xrdp_process *id, int chan_id,
962+
char *data, int bytes, int total_bytes)
964963
{
965-
struct xrdp_process *process;
966964
struct xrdp_egfx *egfx;
967965

968966
LOG(LOG_LEVEL_TRACE, "xrdp_egfx_data_first: bytes %d"
969967
" total_bytes %d", bytes, total_bytes);
970-
process = (struct xrdp_process *) id;
971-
egfx = process->wm->mm->egfx;
968+
egfx = id->wm->mm->egfx;
972969
if (egfx->s != NULL)
973970
{
974971
LOG(LOG_LEVEL_DEBUG, "xrdp_egfx_data_first: Error!"
@@ -983,24 +980,22 @@ xrdp_egfx_data_first(intptr_t id, int chan_id, char *data, int bytes,
983980
/******************************************************************************/
984981
/* from client */
985982
static int
986-
xrdp_egfx_data(intptr_t id, int chan_id, char *data, int bytes)
983+
xrdp_egfx_data(struct xrdp_process *id, int chan_id, char *data, int bytes)
987984
{
988985
int error;
989986
struct stream ls;
990-
struct xrdp_process *process;
991987
struct xrdp_wm *wm;
992988
struct xrdp_mm *mm;
993989
struct xrdp_egfx *egfx;
994990

995991
LOG(LOG_LEVEL_TRACE, "xrdp_egfx_data:");
996992

997-
process = (struct xrdp_process *) id;
998-
if (process == NULL)
993+
if (id == NULL)
999994
{
1000995
return 0;
1001996
}
1002997

1003-
wm = process->wm;
998+
wm = id->wm;
1004999
if (wm == NULL)
10051000
{
10061001
return 0;

xrdp/xrdp_mm.c

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -998,9 +998,9 @@ xrdp_mm_egfx_invalidate_wm_screen(struct xrdp_mm *self)
998998

999999
/******************************************************************************/
10001000
static int
1001-
dynamic_monitor_open_response(intptr_t id, int chan_id, int creation_status)
1001+
dynamic_monitor_open_response(struct xrdp_process *id, int chan_id,
1002+
int creation_status)
10021003
{
1003-
struct xrdp_process *pro;
10041004
struct xrdp_wm *wm;
10051005
struct stream *s;
10061006
int bytes;
@@ -1012,8 +1012,7 @@ dynamic_monitor_open_response(intptr_t id, int chan_id, int creation_status)
10121012
LOG(LOG_LEVEL_ERROR, "dynamic_monitor_open_response: error");
10131013
return 1;
10141014
}
1015-
pro = (struct xrdp_process *) id;
1016-
wm = pro->wm;
1015+
wm = id->wm;
10171016
make_stream(s);
10181017
init_stream(s, 1024);
10191018
out_uint32_le(s, 5); /* DISPLAYCONTROL_PDU_TYPE_CAPS */
@@ -1030,16 +1029,16 @@ dynamic_monitor_open_response(intptr_t id, int chan_id, int creation_status)
10301029

10311030
/******************************************************************************/
10321031
static int
1033-
dynamic_monitor_close_response(intptr_t id, int chan_id)
1032+
dynamic_monitor_close_response(struct xrdp_process *id, int chan_id)
10341033
{
10351034
LOG_DEVEL(LOG_LEVEL_TRACE, "dynamic_monitor_close_response:");
10361035
return 0;
10371036
}
10381037

10391038
/******************************************************************************/
10401039
static int
1041-
dynamic_monitor_data_first(intptr_t id, int chan_id, char *data, int bytes,
1042-
int total_bytes)
1040+
dynamic_monitor_data_first(struct xrdp_process *id, int chan_id,
1041+
char *data, int bytes, int total_bytes)
10431042
{
10441043
LOG_DEVEL(LOG_LEVEL_TRACE, "dynamic_monitor_data_first:");
10451044
return 0;
@@ -1438,21 +1437,20 @@ sync_dynamic_monitor_data(struct xrdp_wm *wm,
14381437

14391438
/******************************************************************************/
14401439
static int
1441-
dynamic_monitor_data(intptr_t id, int chan_id, char *data, int bytes)
1440+
dynamic_monitor_data(struct xrdp_process *id, int chan_id,
1441+
char *data, int bytes)
14421442
{
14431443
int error = 0;
14441444
struct stream ls;
14451445
struct stream *s;
14461446
int msg_type;
14471447
int msg_length;
1448-
struct xrdp_process *pro;
14491448
struct xrdp_wm *wm;
14501449
int monitor_layout_size;
14511450
struct display_size_description *display_size_data;
14521451

14531452
LOG_DEVEL(LOG_LEVEL_TRACE, "dynamic_monitor_data:");
1454-
pro = (struct xrdp_process *) id;
1455-
wm = pro->wm;
1453+
wm = id->wm;
14561454

14571455
if (OUTPUT_SUPPRESSED_FOR_REASON(wm->client_info,
14581456
XSO_REASON_CLIENT_REQUEST))
@@ -2029,19 +2027,18 @@ xrdp_mm_logwnd_fatal(struct xrdp_mm *self, int errinfo)
20292027
/*****************************************************************************/
20302028
/* open response from client going to channel server */
20312029
static int
2032-
xrdp_mm_drdynvc_open_response(intptr_t id, int chan_id, int creation_status)
2030+
xrdp_mm_drdynvc_open_response(struct xrdp_process *id, int chan_id,
2031+
int creation_status)
20332032
{
20342033
struct trans *trans;
20352034
struct stream *s;
20362035
struct xrdp_wm *wm;
2037-
struct xrdp_process *pro;
20382036
int chansrv_chan_id;
20392037

20402038
LOG_DEVEL(LOG_LEVEL_DEBUG, "xrdp_mm_drdynvc_open_response: "
20412039
" chan_id %d creation_status %d",
20422040
chan_id, creation_status);
2043-
pro = (struct xrdp_process *) id;
2044-
wm = pro->wm;
2041+
wm = id->wm;
20452042
trans = wm->mm->chan_trans;
20462043
s = trans_get_out_s(trans, 8192);
20472044
if (s == NULL)
@@ -2062,16 +2059,14 @@ xrdp_mm_drdynvc_open_response(intptr_t id, int chan_id, int creation_status)
20622059
/*****************************************************************************/
20632060
/* close response from client going to channel server */
20642061
static int
2065-
xrdp_mm_drdynvc_close_response(intptr_t id, int chan_id)
2062+
xrdp_mm_drdynvc_close_response(struct xrdp_process *id, int chan_id)
20662063
{
20672064
struct trans *trans;
20682065
struct stream *s;
20692066
struct xrdp_wm *wm;
2070-
struct xrdp_process *pro;
20712067
int chansrv_chan_id;
20722068

2073-
pro = (struct xrdp_process *) id;
2074-
wm = pro->wm;
2069+
wm = id->wm;
20752070
trans = wm->mm->chan_trans;
20762071
s = trans_get_out_s(trans, 8192);
20772072
if (s == NULL)
@@ -2091,17 +2086,15 @@ xrdp_mm_drdynvc_close_response(intptr_t id, int chan_id)
20912086
/*****************************************************************************/
20922087
/* part data from client going to channel server */
20932088
static int
2094-
xrdp_mm_drdynvc_data_first(intptr_t id, int chan_id, char *data,
2089+
xrdp_mm_drdynvc_data_first(struct xrdp_process *id, int chan_id, char *data,
20952090
int bytes, int total_bytes)
20962091
{
20972092
struct trans *trans;
20982093
struct stream *s;
20992094
struct xrdp_wm *wm;
2100-
struct xrdp_process *pro;
21012095
int chansrv_chan_id;
21022096

2103-
pro = (struct xrdp_process *) id;
2104-
wm = pro->wm;
2097+
wm = id->wm;
21052098
trans = wm->mm->chan_trans;
21062099
s = trans_get_out_s(trans, 8192);
21072100
if (s == NULL)
@@ -2124,16 +2117,15 @@ xrdp_mm_drdynvc_data_first(intptr_t id, int chan_id, char *data,
21242117
/*****************************************************************************/
21252118
/* data from client going to channel server */
21262119
static int
2127-
xrdp_mm_drdynvc_data(intptr_t id, int chan_id, char *data, int bytes)
2120+
xrdp_mm_drdynvc_data(struct xrdp_process *id, int chan_id,
2121+
char *data, int bytes)
21282122
{
21292123
struct trans *trans;
21302124
struct stream *s;
21312125
struct xrdp_wm *wm;
2132-
struct xrdp_process *pro;
21332126
int chansrv_chan_id;
21342127

2135-
pro = (struct xrdp_process *) id;
2136-
wm = pro->wm;
2128+
wm = id->wm;
21372129
trans = wm->mm->chan_trans;
21382130
s = trans_get_out_s(trans, 8192);
21392131
if (s == NULL)

xrdp/xrdp_process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ xrdp_process_main_loop(struct xrdp_process *self)
236236
self->server_trans->trans_data_in = xrdp_process_data_in;
237237
self->server_trans->callback_data = self;
238238
init_stream(self->server_trans->in_s, 8192 * 4);
239-
self->session = libxrdp_init((tbus)self, self->server_trans,
239+
self->session = libxrdp_init(self, self->server_trans,
240240
self->lis_layer->startup_params->xrdp_ini);
241241
self->server_trans->si = &(self->session->si);
242242
self->server_trans->my_source = XRDP_SOURCE_CLIENT;

xrdp/xrdp_wm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,14 +2095,14 @@ xrdp_wm_process_channel_data(struct xrdp_wm *self,
20952095
/******************************************************************************/
20962096
/* this is the callbacks coming from libxrdp.so */
20972097
int
2098-
callback(intptr_t id, int msg, intptr_t param1, intptr_t param2,
2098+
callback(struct xrdp_process *id, int msg, intptr_t param1, intptr_t param2,
20992099
intptr_t param3, intptr_t param4)
21002100
{
21012101
int rv;
21022102
struct xrdp_wm *wm;
21032103
struct xrdp_rect rect;
21042104

2105-
if (id == 0) /* "id" should be "struct xrdp_process*" as long */
2105+
if (id == NULL)
21062106
{
21072107
return 0;
21082108
}

0 commit comments

Comments
 (0)