diff options
author | Nicola Ruggero <nicola@nxnt.org> | 2010-11-03 16:59:26 +0100 |
---|---|---|
committer | Nicola Ruggero <nicola@nxnt.org> | 2010-11-03 16:59:26 +0100 |
commit | 4cf06dbbcb8522be5fa069976c8f361fc874039f (patch) | |
tree | 6e074a89c4edadf9a75d648d1f9daf36079c03aa /rdp | |
parent | 104f762e5d3dcd659415632f442e745cef5a3bf2 (diff) | |
download | xrdp-proprietary-4cf06dbbcb8522be5fa069976c8f361fc874039f.tar.gz xrdp-proprietary-4cf06dbbcb8522be5fa069976c8f361fc874039f.zip |
Major code cleanup:
- Initialized and zeroed out local variables
- Check for some null pointers
- Fixed some typos
- Other minor changes (beautify, etc.)
Diffstat (limited to 'rdp')
-rw-r--r-- | rdp/rdp_orders.c | 190 | ||||
-rw-r--r-- | rdp/rdp_rdp.c | 82 |
2 files changed, 141 insertions, 131 deletions
diff --git a/rdp/rdp_orders.c b/rdp/rdp_orders.c index 50d20e96..c0da6c35 100644 --- a/rdp/rdp_orders.c +++ b/rdp/rdp_orders.c @@ -22,11 +22,15 @@ #include "rdp.h" +#ifndef NULL +#define NULL 0 +#endif + /*****************************************************************************/ struct rdp_orders* APP_CC rdp_orders_create(struct rdp_rdp* owner) { - struct rdp_orders* self; + struct rdp_orders* self = (struct rdp_orders *)NULL; self = (struct rdp_orders*)g_malloc(sizeof(struct rdp_orders), 1); self->rdp_layer = owner; @@ -37,8 +41,8 @@ rdp_orders_create(struct rdp_rdp* owner) void APP_CC rdp_orders_delete(struct rdp_orders* self) { - int i; - int j; + int i = 0; + int j = 0; if (self == 0) { @@ -77,8 +81,8 @@ static void APP_CC rdp_orders_in_present(struct stream* s, int* present, int flags, int size) { - int bits; - int i; + int bits = 0; + int i = 0; if (flags & RDP_ORDER_SMALL) { @@ -108,7 +112,7 @@ rdp_orders_in_present(struct stream* s, int* present, static void APP_CC rdp_orders_in_coord(struct stream* s, int* coord, int delta) { - int change; + int change = 0; if (delta) { @@ -126,7 +130,7 @@ rdp_orders_in_coord(struct stream* s, int* coord, int delta) static void APP_CC rdp_orders_parse_bounds(struct rdp_orders* self, struct stream* s) { - int present; + int present = 0; in_uint8(s, present); if (present & 1) @@ -169,10 +173,10 @@ static void APP_CC rdp_orders_process_colcache(struct rdp_orders* self, struct stream* s, int flags) { - struct rdp_colormap* colormap; - struct stream* rec_s; - int cache_id; - int i; + struct rdp_colormap* colormap = (struct rdp_colormap *)NULL; + struct stream* rec_s = (struct stream *)NULL; + int cache_id = 0; + int i = 0; colormap = (struct rdp_colormap*)g_malloc(sizeof(struct rdp_colormap), 1); in_uint8(s, cache_id); @@ -206,19 +210,19 @@ static void APP_CC rdp_orders_process_raw_bmpcache(struct rdp_orders* self, struct stream* s, int flags) { - int cache_idx; - int bufsize; - int cache_id; - int width; - int height; - int bpp; - int Bpp; - int x; - int y; - char* inverted; - char* dst; - struct rdp_bitmap* bitmap; - struct stream* rec_s; + int cache_idx = 0; + int bufsize = 0; + int cache_id = 0; + int width = 0; + int height = 0; + int bpp = 0; + int Bpp = 0; + int x = 0; + int y = 0; + char* inverted = (char *)NULL; + char* dst = (char *)NULL; + struct rdp_bitmap* bitmap = (struct rdp_bitmap *)NULL; + struct stream* rec_s = (struct stream *)NULL; in_uint8(s, cache_id); in_uint8s(s, 1); @@ -292,22 +296,22 @@ static void APP_CC rdp_orders_process_bmpcache(struct rdp_orders* self, struct stream* s, int flags) { - char* data; - char* bmpdata; - int cache_idx; - int size; - int cache_id; - int width; - int height; - int bpp; - int Bpp; - int bufsize; - int pad1; - int pad2; - int row_size; - int final_size; - struct rdp_bitmap* bitmap; - struct stream* rec_s; + char* data = (char *)NULL; + char* bmpdata = (char *)NULL; + int cache_idx = 0; + int size = 0; + int cache_id = 0; + int width = 0; + int height = 0; + int bpp = 0; + int Bpp = 0; + int bufsize = 0; + int pad1 = 0; + int pad2 = 0; + int row_size = 0; + int final_size = 0; + struct rdp_bitmap* bitmap = (struct rdp_bitmap *)NULL; + struct stream* rec_s = (struct stream *)NULL; in_uint8(s, cache_id); in_uint8(s, pad1); @@ -373,17 +377,17 @@ static void APP_CC rdp_orders_process_fontcache(struct rdp_orders* self, struct stream* s, int flags) { - struct stream* rec_s; - int font; - int nglyphs; - int character; - int offset; - int baseline; - int width; - int height; - int i; - int datasize; - char* data; + struct stream* rec_s = (struct stream *)NULL; + int font = 0; + int nglyphs = 0; + int character = 0; + int offset = 0; + int baseline = 0; + int width = 0; + int height = 0; + int i = 0; + int datasize = 0; + char* data = (char *)NULL; in_uint8(s, font); in_uint8(s, nglyphs); @@ -425,10 +429,10 @@ rdp_orders_process_fontcache(struct rdp_orders* self, struct stream* s, static int APP_CC rdp_orders_process_secondary_order(struct rdp_orders* self, struct stream* s) { - short length; - int flags; - int type; - char* next_order; + short length = 0; + int flags = 0; + int type = 0; + char* next_order = (char *)NULL; in_uint16_le(s, length); in_uint16_le(s, flags); @@ -461,7 +465,7 @@ rdp_orders_process_secondary_order(struct rdp_orders* self, struct stream* s) static void APP_CC rdp_orders_in_color(struct stream* s, int* color) { - int i; + int i = 0; in_uint8(s, i); *color = i; @@ -523,9 +527,9 @@ static void APP_CC rdp_orders_process_text2(struct rdp_orders* self, struct stream* s, int present, int delta) { - int fgcolor; - int bgcolor; - struct stream* rec_s; + int fgcolor = 0; + int bgcolor = 0; + struct stream* rec_s = (struct stream *)NULL; if (present & 0x000001) { @@ -662,7 +666,7 @@ static void APP_CC rdp_orders_process_destblt(struct rdp_orders* self, struct stream* s, int present, int delta) { - struct stream* rec_s; + struct stream* rec_s = (struct stream *)NULL; if (present & 0x01) { @@ -715,9 +719,9 @@ static void APP_CC rdp_orders_process_patblt(struct rdp_orders* self, struct stream* s, int present, int delta) { - int fgcolor; - int bgcolor; - struct stream* rec_s; + int fgcolor = 0; + int bgcolor = 0; + struct stream* rec_s = (struct stream *)NULL; if (present & 0x0001) { @@ -867,9 +871,9 @@ static void APP_CC rdp_orders_process_line(struct rdp_orders* self, struct stream* s, int present, int delta) { - int bgcolor; - int fgcolor; - struct stream* rec_s; + int bgcolor = 0; + int fgcolor = 0; + struct stream* rec_s = (struct stream *)NULL; if (present & 0x0001) { @@ -949,9 +953,9 @@ static void APP_CC rdp_orders_process_rect(struct rdp_orders* self, struct stream* s, int present, int delta) { - int i; - int fgcolor; - struct stream* rec_s; + int i = 0; + int fgcolor = 0; + struct stream* rec_s = (struct stream *)NULL; if (present & 0x01) { @@ -1017,8 +1021,8 @@ static void APP_CC rdp_orders_process_desksave(struct rdp_orders* self, struct stream* s, int present, int delta) { - int width; - int height; + int width = 0; + int height = 0; if (present & 0x01) { @@ -1062,9 +1066,9 @@ static void APP_CC rdp_orders_process_memblt(struct rdp_orders* self, struct stream* s, int present, int delta) { - struct rdp_bitmap* bitmap; - struct stream* rec_s; - char* bmpdata; + struct rdp_bitmap* bitmap = (struct rdp_bitmap *)NULL; + struct stream* rec_s = (struct stream *)NULL; + char* bmpdata = (char *)NULL; if (present & 0x0001) { @@ -1200,11 +1204,11 @@ int APP_CC rdp_orders_process_orders(struct rdp_orders* self, struct stream* s, int num_orders) { - int processed; - int order_flags; - int size; - int present; - int delta; + int processed = 0; + int order_flags = 0; + int size = 0; + int present = 0; + int delta = 0; processed = 0; while (processed < num_orders) @@ -1308,15 +1312,15 @@ char* APP_CC rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata, int width, int height, int* palette) { - char* out; - char* src; - char* dst; - int i; - int j; - int red; - int green; - int blue; - int pixel; + char* out = (char *)NULL; + char* src = (char *)NULL; + char* dst = (char *)NULL; + int i = 0; + int j = 0; + int red = 0; + int green = 0; + int blue = 0; + int pixel = 0; if ((in_bpp == 8) && (out_bpp == 8)) { @@ -1372,7 +1376,7 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata, SPLITCOLOR32(red, green, blue, pixel); pixel = COLOR24RGB(red, green, blue); *((tui32*)dst) = pixel; - src++;; + src++; dst += 4; } } @@ -1469,10 +1473,10 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata, int APP_CC rdp_orders_convert_color(int in_bpp, int out_bpp, int in_color, int* palette) { - int pixel; - int red; - int green; - int blue; + int pixel = 0; + int red = 0; + int green = 0; + int blue = 0; if ((in_bpp == 8) && (out_bpp == 8)) { diff --git a/rdp/rdp_rdp.c b/rdp/rdp_rdp.c index e3bd45bc..b3c6d42a 100644 --- a/rdp/rdp_rdp.c +++ b/rdp/rdp_rdp.c @@ -22,6 +22,10 @@ #include "rdp.h" +#ifndef NULL +#define NULL 0 +#endif + /*****************************************************************************/ struct rdp_rdp* APP_CC rdp_rdp_create(struct mod* owner) @@ -222,7 +226,7 @@ rdp_rdp_out_order_caps(struct rdp_rdp* self, struct stream* s) static int APP_CC rdp_rdp_out_bmpcache_caps(struct rdp_rdp* self, struct stream* s) { - int Bpp; + int Bpp = 0; out_uint16_le(s, RDP_CAPSET_BMPCACHE); out_uint16_le(s, RDP_CAPLEN_BMPCACHE); @@ -508,26 +512,26 @@ rdp_rdp_process_pointer_pdu(struct rdp_rdp* self, struct stream* s) static void APP_CC rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s) { - int num_updates; - int left; - int top; - int right; - int bottom; - int width; - int height; - int cx; - int cy; - int bpp; - int Bpp; - int compress; - int bufsize; - int size; - int i; - int x; - int y; - char* data; - char* bmpdata0; - char* bmpdata1; + int num_updates = 0; + int left = 0; + int top = 0; + int right = 0; + int bottom = 0; + int width = 0; + int height = 0; + int cx = 0; + int cy = 0; + int bpp = 0; + int Bpp = 0; + int compress = 0; + int bufsize = 0; + int size = 0; + int i = 0; + int x = 0; + int y = 0; + char* data = NULL; + char* bmpdata0 = NULL; + char* bmpdata1 = NULL; in_uint16_le(s, num_updates); for (i = 0; i < num_updates; i++) @@ -915,9 +919,9 @@ rdp_rdp_process_general_caps(struct rdp_rdp* self, struct stream* s) static void APP_CC rdp_rdp_process_bitmap_caps(struct rdp_rdp* self, struct stream* s) { - int width; - int height; - int bpp; + int width = 0; + int height = 0; + int bpp = 0; in_uint16_le(s, bpp); in_uint8s(s, 6); @@ -933,12 +937,12 @@ rdp_rdp_process_bitmap_caps(struct rdp_rdp* self, struct stream* s) static int APP_CC rdp_rdp_process_server_caps(struct rdp_rdp* self, struct stream* s, int len) { - int n; - int ncapsets; - int capset_type; - int capset_length; - char* next; - char* start; + int n = 0; + int ncapsets = 0; + int capset_type = 0; + int capset_length = 0; + char* next = NULL; + char* start = NULL; start = s->p; in_uint16_le(s, ncapsets); @@ -1035,9 +1039,9 @@ rdp_rdp_send_fonts(struct rdp_rdp* self, struct stream* s, int seq) int APP_CC rdp_rdp_process_demand_active(struct rdp_rdp* self, struct stream* s) { - int type; - int len_src_descriptor; - int len_combined_caps; + int type = 0; + int len_src_descriptor = 0; + int len_combined_caps = 0; in_uint32_le(s, self->share_id); in_uint16_le(s, len_src_descriptor); @@ -1064,9 +1068,11 @@ int APP_CC rdp_rec_check_file(struct rdp_rdp* self) { char file_name[256]; - int index; - int len; - struct stream* s; + int index = 0; + int len = 0; + struct stream* s = (struct stream *)NULL; + + g_memset(file_name,0,sizeof(char) * 256); if (self->rec_fd == 0) { @@ -1098,8 +1104,8 @@ rdp_rec_check_file(struct rdp_rdp* self) int APP_CC rdp_rec_write_item(struct rdp_rdp* self, struct stream* s) { - int len; - int time; + int len = 0; + int time = 0; if (self->rec_fd == 0) { |