From 896a923f55f8d035eb20e517e743be1ce117fd5c Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Fri, 20 Oct 2017 11:05:52 +0200 Subject: [PATCH 1/6] Markup unused parameters --- bitmap.c | 1 + channels.c | 1 + cssp.c | 1 + ctrl.c | 1 + disk.c | 5 +++++ iso.c | 1 + lspci.c | 2 ++ mcs.c | 1 + orders.c | 2 ++ parallel.c | 10 ++++++++++ printer.c | 6 ++++++ rdpsnd.c | 3 +++ rdpsnd_alsa.c | 1 + rdpsnd_dsp.c | 1 + rdpsnd_oss.c | 1 + scard.c | 26 +++++++++++++++++++++++++- seamless.c | 1 + serial.c | 7 +++++++ ssl.c | 8 ++++++++ 19 files changed, 78 insertions(+), 1 deletion(-) diff --git a/bitmap.c b/bitmap.c index ed10f9e..8c4a04c 100644 --- a/bitmap.c +++ b/bitmap.c @@ -749,6 +749,7 @@ bitmap_decompress3(uint8 * output, int width, int height, uint8 * input, int siz static int process_plane(uint8 * in, int width, int height, uint8 * out, int size) { + UNUSED(size); int indexw; int indexh; int code; diff --git a/channels.c b/channels.c index 3c7e8ea..fd81b59 100644 --- a/channels.c +++ b/channels.c @@ -69,6 +69,7 @@ channel_register(char *name, uint32 flags, void (*callback) (STREAM)) STREAM channel_init(VCHANNEL * channel, uint32 length) { + UNUSED(channel); STREAM s; s = sec_init(g_encryption ? SEC_ENCRYPT : 0, length + 8); diff --git a/cssp.c b/cssp.c index db92733..b1dbe69 100644 --- a/cssp.c +++ b/cssp.c @@ -680,6 +680,7 @@ cssp_read_tsrequest(STREAM token, STREAM pubkey) RD_BOOL cssp_connect(char *server, char *user, char *domain, char *password, STREAM s) { + UNUSED(s); OM_uint32 actual_time; gss_cred_id_t cred; gss_buffer_desc input_tok, output_tok; diff --git a/ctrl.c b/ctrl.c index 744aee5..6a36157 100644 --- a/ctrl.c +++ b/ctrl.c @@ -365,6 +365,7 @@ ctrl_add_fds(int *n, fd_set * rfds) void ctrl_check_fds(fd_set * rfds, fd_set * wfds) { + UNUSED(wfds); int ns, res, offs; struct sockaddr_un fsaun; socklen_t fromlen; diff --git a/disk.c b/disk.c index e720815..36fac03 100644 --- a/disk.c +++ b/disk.c @@ -739,6 +739,7 @@ disk_query_information(RD_NTHANDLE handle, uint32 info_class, STREAM out) RD_NTSTATUS disk_set_information(RD_NTHANDLE handle, uint32 info_class, STREAM in, STREAM out) { + UNUSED(out); uint32 length, file_attributes, ft_high, ft_low; char *newname, fullpath[PATH_MAX]; struct fileinfo *pfinfo; @@ -1007,6 +1008,7 @@ disk_create_notify(RD_NTHANDLE handle, uint32 info_class) static RD_NTSTATUS NotifyInfo(RD_NTHANDLE handle, uint32 info_class, NOTIFY * p) { + UNUSED(info_class); struct fileinfo *pfinfo; struct stat filestat; struct dirent *dp; @@ -1421,6 +1423,9 @@ disk_query_directory(RD_NTHANDLE handle, uint32 info_class, char *pattern, STREA static RD_NTSTATUS disk_device_control(RD_NTHANDLE handle, uint32 request, STREAM in, STREAM out) { + UNUSED(in); + UNUSED(out); + logger(Disk, Debug, "disk_device_control(handle=0x%x, request=0x%x, ...)", handle, request); if (((request >> 16) != 20) || ((request >> 16) != 9)) return RD_STATUS_INVALID_PARAMETER; diff --git a/iso.c b/iso.c index 20702e7..1b5ff1c 100644 --- a/iso.c +++ b/iso.c @@ -204,6 +204,7 @@ RD_BOOL iso_connect(char *server, char *username, char *domain, char *password, RD_BOOL reconnect, uint32 * selected_protocol) { + UNUSED(reconnect); STREAM s; uint8 code; uint32 neg_proto; diff --git a/lspci.c b/lspci.c index d0670dd..ee5e164 100644 --- a/lspci.c +++ b/lspci.c @@ -43,6 +43,7 @@ static void lspci_send(const char *output); static RD_BOOL handle_child_line(const char *line, void *data) { + UNUSED(data); const char *val; char buf[1024]; @@ -108,6 +109,7 @@ handle_child_line(const char *line, void *data) static RD_BOOL lspci_process_line(const char *line, void *data) { + UNUSED(data); char *lspci_command[5] = { "lspci", "-m", "-n", "-v", NULL }; if (!strcmp(line, "LSPCI")) diff --git a/mcs.c b/mcs.c index 53e5af9..8ddf1d0 100644 --- a/mcs.c +++ b/mcs.c @@ -86,6 +86,7 @@ mcs_send_connect_initial(STREAM mcs_data) static RD_BOOL mcs_recv_connect_response(STREAM mcs_data) { + UNUSED(mcs_data); uint8 result; int length; STREAM s; diff --git a/orders.c b/orders.c index 48fa584..ba9cfa1 100644 --- a/orders.c +++ b/orders.c @@ -826,6 +826,7 @@ process_ellipse2(STREAM s, ELLIPSE2_ORDER * os, uint32 present, RD_BOOL delta) static void process_text2(STREAM s, TEXT2_ORDER * os, uint32 present, RD_BOOL delta) { + UNUSED(delta); BRUSH brush; if (present & 0x000001) @@ -1175,6 +1176,7 @@ process_compressed_8x8_brush_data(uint8 * in, uint8 * out, int Bpp) static void process_brushcache(STREAM s, uint16 flags) { + UNUSED(flags); BRUSHDATA brush_data; uint8 cache_idx, colour_code, width, height, size, type; uint8 *comp_brush; diff --git a/parallel.c b/parallel.c index f74bede..59ba7e9 100644 --- a/parallel.c +++ b/parallel.c @@ -78,6 +78,11 @@ static RD_NTSTATUS parallel_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, uint32 flags, char *filename, RD_NTHANDLE * handle) { + UNUSED(access); + UNUSED(share_mode); + UNUSED(disposition); + UNUSED(flags); + UNUSED(filename); int parallel_fd; parallel_fd = open(g_rdpdr_device[device_id].local_path, O_RDWR); @@ -116,6 +121,7 @@ parallel_close(RD_NTHANDLE handle) static RD_NTSTATUS parallel_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { + UNUSED(offset); *result = read(handle, data, length); return RD_STATUS_SUCCESS; } @@ -123,6 +129,7 @@ parallel_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, ui static RD_NTSTATUS parallel_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { + UNUSED(offset); int rc = RD_STATUS_SUCCESS; int n = write(handle, data, length); @@ -158,6 +165,9 @@ parallel_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, u static RD_NTSTATUS parallel_device_control(RD_NTHANDLE handle, uint32 request, STREAM in, STREAM out) { + UNUSED(handle); + UNUSED(in); + UNUSED(out); if ((request >> 16) != FILE_DEVICE_PARALLEL) return RD_STATUS_INVALID_PARAMETER; diff --git a/printer.c b/printer.c index 06a1e95..acd38ed 100644 --- a/printer.c +++ b/printer.c @@ -103,6 +103,11 @@ static RD_NTSTATUS printer_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, uint32 flags, char *filename, RD_NTHANDLE * handle) { + UNUSED(access); + UNUSED(share_mode); + UNUSED(disposition); + UNUSED(flags); + UNUSED(filename); char cmd[256]; PRINTER *pprinter_data; @@ -141,6 +146,7 @@ printer_close(RD_NTHANDLE handle) static RD_NTSTATUS printer_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { + UNUSED(offset); PRINTER *pprinter_data; pprinter_data = get_printer_data(handle); diff --git a/rdpsnd.c b/rdpsnd.c index 3ef7361..0d70870 100644 --- a/rdpsnd.c +++ b/rdpsnd.c @@ -110,6 +110,8 @@ rdpsnd_send_waveconfirm(uint16 tick, uint8 packet_index) void rdpsnd_record(const void *data, unsigned int size) { + UNUSED(data); + UNUSED(size); /* TODO: Send audio over RDP */ } @@ -430,6 +432,7 @@ rdpsnd_process(STREAM s) static RD_BOOL rdpsnddbg_line_handler(const char *line, void *data) { + UNUSED(data); logger(Sound, Debug, "rdpsnddbg_line_handler(), \"%s\"", line); return True; } diff --git a/rdpsnd_alsa.c b/rdpsnd_alsa.c index 66e741d..f5a0bcd 100644 --- a/rdpsnd_alsa.c +++ b/rdpsnd_alsa.c @@ -59,6 +59,7 @@ void alsa_record(void); void alsa_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv) { + UNUSED(tv); int err; struct pollfd *f; diff --git a/rdpsnd_dsp.c b/rdpsnd_dsp.c index b815a44..60c6f04 100644 --- a/rdpsnd_dsp.c +++ b/rdpsnd_dsp.c @@ -179,6 +179,7 @@ uint32 rdpsnd_dsp_resample(unsigned char **out, unsigned char *in, unsigned int size, RD_WAVEFORMATEX * format, RD_BOOL stream_be) { + UNUSED(stream_be); #ifdef HAVE_LIBSAMPLERATE SRC_DATA resample_data; float *infloat, *outfloat; diff --git a/rdpsnd_oss.c b/rdpsnd_oss.c index 2170906..98e7e70 100644 --- a/rdpsnd_oss.c +++ b/rdpsnd_oss.c @@ -71,6 +71,7 @@ static RD_BOOL oss_set_format(RD_WAVEFORMATEX * pwfx); static void oss_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv) { + UNUSED(tv); if (dsp_fd == -1) return; diff --git a/scard.c b/scard.c index 40dd8fd..f6c324b 100644 --- a/scard.c +++ b/scard.c @@ -99,24 +99,43 @@ static RD_NTSTATUS scard_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition, uint32 flags_and_attributes, char *filename, RD_NTHANDLE * phandle) { - return RD_STATUS_SUCCESS; + UNUSED(device_id); + UNUSED(accessmask); + UNUSED(sharemode); + UNUSED(create_disposition); + UNUSED(flags_and_attributes); + UNUSED(filename); + UNUSED(phandle); + + return RD_STATUS_SUCCESS; } static RD_NTSTATUS scard_close(RD_NTHANDLE handle) { + UNUSED(handle); return RD_STATUS_SUCCESS; } static RD_NTSTATUS scard_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { + UNUSED(handle); + UNUSED(data); + UNUSED(length); + UNUSED(offset); + UNUSED(result); return RD_STATUS_SUCCESS; } static RD_NTSTATUS scard_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { + UNUSED(handle); + UNUSED(data); + UNUSED(length); + UNUSED(offset); + UNUSED(result); return RD_STATUS_SUCCESS; } @@ -644,6 +663,7 @@ inSkipLinked(STREAM in) static MYPCSC_DWORD SC_returnCode(MYPCSC_DWORD rc, PMEM_HANDLE * handle, STREAM in, STREAM out) { + UNUSED(in); SC_xfreeallmemory(handle); out_uint8s(out, 256); return rc; @@ -658,6 +678,7 @@ SC_returnNoMemoryError(PMEM_HANDLE * handle, STREAM in, STREAM out) static MYPCSC_DWORD TS_SCardEstablishContext(STREAM in, STREAM out) { + UNUSED(in); MYPCSC_DWORD rv; MYPCSC_SCARDCONTEXT myHContext; SERVER_SCARDCONTEXT hContext; @@ -2255,6 +2276,7 @@ TS_SCardControl(STREAM in, STREAM out) static MYPCSC_DWORD TS_SCardAccessStartedEvent(STREAM in, STREAM out) { + UNUSED(in); logger(SmartCard, Debug, "TS_SCardAccessStartedEvent()"); out_uint8s(out, 8); return SCARD_S_SUCCESS; @@ -2264,6 +2286,7 @@ TS_SCardAccessStartedEvent(STREAM in, STREAM out) static RD_NTSTATUS scard_device_control(RD_NTHANDLE handle, uint32 request, STREAM in, STREAM out) { + UNUSED(handle); SERVER_DWORD Result = 0x00000000; unsigned char *psize, *pend, *pStatusCode; SERVER_DWORD addToEnd = 0; @@ -2652,6 +2675,7 @@ SC_handleRequest(PSCThreadData data) static void * queue_handler_function(void *data) { + UNUSED(data); PSCThreadData cur_data = NULL; while (1) { diff --git a/seamless.c b/seamless.c index 33f4cbf..53d3a0c 100644 --- a/seamless.c +++ b/seamless.c @@ -56,6 +56,7 @@ seamless_get_token(char **s) static RD_BOOL seamless_process_line(const char *line, void *data) { + UNUSED(data); char *p, *l; char *tok1, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8; unsigned long id, flags; diff --git a/serial.c b/serial.c index 2cb441e..7ad2f74 100644 --- a/serial.c +++ b/serial.c @@ -552,6 +552,11 @@ static RD_NTSTATUS serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposition, uint32 flags_and_attributes, char *filename, RD_NTHANDLE * handle) { + UNUSED(access); + UNUSED(share_mode); + UNUSED(disposition); + UNUSED(flags_and_attributes); + UNUSED(filename); RD_NTHANDLE serial_fd; SERIAL_DEVICE *pser_inf; @@ -625,6 +630,7 @@ serial_close(RD_NTHANDLE handle) static RD_NTSTATUS serial_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { + UNUSED(offset); long timeout; SERIAL_DEVICE *pser_inf; struct termios *ptermios; @@ -680,6 +686,7 @@ serial_read(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint static RD_NTSTATUS serial_write(RD_NTHANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result) { + UNUSED(offset); SERIAL_DEVICE *pser_inf; /* FIXME: offset is not used ? */ diff --git a/ssl.c b/ssl.c index eb2066f..3139e6f 100644 --- a/ssl.c +++ b/ssl.c @@ -251,6 +251,8 @@ rdssl_cert_to_rkey(RDSSL_CERT * cert, uint32 * key_len) RD_BOOL rdssl_certs_ok(RDSSL_CERT * server_cert, RDSSL_CERT * cacert) { + UNUSED(server_cert); + UNUSED(cacert); /* Currently, we don't use the CA Certificate. FIXME: *) Verify the server certificate (server_cert) with the @@ -308,6 +310,12 @@ RD_BOOL rdssl_sig_ok(uint8 * exponent, uint32 exp_len, uint8 * modulus, uint32 mod_len, uint8 * signature, uint32 sig_len) { + UNUSED(exponent); + UNUSED(exp_len); + UNUSED(modulus); + UNUSED(mod_len); + UNUSED(signature); + UNUSED(sig_len); /* Currently, we don't check the signature FIXME: */ From 0d707ae103dc86db9a1c1c99bc709c24b373062b Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Fri, 20 Oct 2017 12:13:21 +0200 Subject: [PATCH 2/6] Fix sign-compare compiler warnings --- disk.c | 2 +- ewmhints.c | 9 ++++----- printer.c | 2 +- proto.h | 20 ++++++++++---------- rdpdr.c | 12 ++++++------ rdpsnd_alsa.c | 6 +++--- scard.c | 16 ++++++++-------- serial.c | 4 ++-- stream.c | 5 ++--- utils.c | 5 +++-- xclip.c | 4 ++-- xwin.c | 28 ++++++++++++++-------------- 12 files changed, 56 insertions(+), 57 deletions(-) diff --git a/disk.c b/disk.c index 36fac03..d113729 100644 --- a/disk.c +++ b/disk.c @@ -349,7 +349,7 @@ static RD_NTSTATUS disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition, uint32 flags_and_attributes, char *filename, RD_NTHANDLE * phandle) { - RD_NTHANDLE handle; + int handle; DIR *dirp; int flags, mode; char path[PATH_MAX]; diff --git a/ewmhints.c b/ewmhints.c index 94ccd8b..a9da552 100644 --- a/ewmhints.c +++ b/ewmhints.c @@ -246,7 +246,7 @@ ewmh_modify_state(Window wnd, int add, Atom atom1, Atom atom2) XEvent xevent; int result; - unsigned long nitems; + unsigned long i, nitems; unsigned char *props; uint32 state = WithdrawnState; @@ -281,7 +281,6 @@ ewmh_modify_state(Window wnd, int add, Atom atom1, Atom atom2) else { Atom *atoms; - int i; if (get_property_value(wnd, "_NET_WM_STATE", 64, &nitems, &props, 1) < 0) return 0; @@ -438,7 +437,7 @@ ewmh_set_window_modal(Window wnd) } void -ewmh_set_icon(Window wnd, int width, int height, const char *rgba_data) +ewmh_set_icon(Window wnd, uint32 width, uint32 height, const char *rgba_data) { unsigned long nitems, i; unsigned char *props; @@ -481,7 +480,7 @@ ewmh_set_icon(Window wnd, int width, int height, const char *rgba_data) icon[1] = height; /* Convert RGBA -> ARGB */ - for (i = 0; i < width * height; i++) + for (i = 0; i < (width * height); i++) { icon[i + 2] = rgba_data[i * 4 + 3] << 24 | @@ -500,7 +499,7 @@ ewmh_set_icon(Window wnd, int width, int height, const char *rgba_data) } void -ewmh_del_icon(Window wnd, int width, int height) +ewmh_del_icon(Window wnd, uint32 width, uint32 height) { unsigned long nitems, i, icon_size; unsigned char *props; diff --git a/printer.c b/printer.c index acd38ed..6b77d5a 100644 --- a/printer.c +++ b/printer.c @@ -40,7 +40,7 @@ printer_enum_devices(uint32 * id, char *optarg) char *pos = optarg; char *pos2; - int count = 0; + size_t count = 0; int already = 0; /* we need to know how many printers we've already set up diff --git a/proto.h b/proto.h index acd04c1..4b88234 100644 --- a/proto.h +++ b/proto.h @@ -271,7 +271,7 @@ void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 void ui_destroy_bitmap(RD_HBITMAP bmp); RD_HGLYPH ui_create_glyph(int width, int height, uint8 * data); void ui_destroy_glyph(RD_HGLYPH glyph); -RD_HCURSOR ui_create_cursor(unsigned int x, unsigned int y, int width, int height, uint8 * andmask, +RD_HCURSOR ui_create_cursor(unsigned int x, unsigned int y, uint32 width, uint32 height, uint8 * andmask, uint8 * xormask, int bpp); void ui_set_cursor(RD_HCURSOR cursor); void ui_destroy_cursor(RD_HCURSOR cursor); @@ -284,24 +284,24 @@ void ui_set_clip(int x, int y, int cx, int cy); void ui_reset_clip(void); void ui_bell(void); void ui_destblt(uint8 opcode, int x, int y, int cx, int cy); -void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, BRUSH * brush, int bgcolour, - int fgcolour); +void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, BRUSH * brush, uint32 bgcolour, + uint32 fgcolour); void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy); void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, RD_HBITMAP src, int srcx, int srcy); void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, RD_HBITMAP src, int srcx, int srcy, - BRUSH * brush, int bgcolour, int fgcolour); + BRUSH * brush, uint32 bgcolour, uint32 fgcolour); void ui_line(uint8 opcode, int startx, int starty, int endx, int endy, PEN * pen); -void ui_rect(int x, int y, int cx, int cy, int colour); +void ui_rect(int x, int y, int cx, int cy, uint32 colour); void ui_polygon(uint8 opcode, uint8 fillmode, RD_POINT * point, int npoints, BRUSH * brush, - int bgcolour, int fgcolour); + uint32 bgcolour, uint32 fgcolour); void ui_polyline(uint8 opcode, RD_POINT * points, int npoints, PEN * pen); void ui_ellipse(uint8 opcode, uint8 fillmode, int x, int y, int cx, int cy, BRUSH * brush, - int bgcolour, int fgcolour); + uint32 bgcolour, uint32 fgcolour); void ui_draw_glyph(int mixmode, int x, int y, int cx, int cy, RD_HGLYPH glyph, int srcx, int srcy, - int bgcolour, int fgcolour); + uint32 bgcolour, uint32 fgcolour); void ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, - BRUSH * brush, int bgcolour, int fgcolour, uint8 * text, uint8 length); + BRUSH * brush, uint32 bgcolour, uint32 fgcolour, uint8 * text, uint8 length); void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy); void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy); void ui_begin_update(void); @@ -316,7 +316,7 @@ void ui_seamless_create_window(unsigned long id, unsigned long group, unsigned l void ui_seamless_destroy_window(unsigned long id, unsigned long flags); void ui_seamless_destroy_group(unsigned long id, unsigned long flags); void ui_seamless_seticon(unsigned long id, const char *format, int width, int height, int chunk, - const char *data, int chunk_len); + const char *data, size_t chunk_len); void ui_seamless_delicon(unsigned long id, const char *format, int width, int height); void ui_seamless_move_window(unsigned long id, int x, int y, int width, int height, unsigned long flags); diff --git a/rdpdr.c b/rdpdr.c index 08a44b4..2da0f55 100644 --- a/rdpdr.c +++ b/rdpdr.c @@ -123,7 +123,7 @@ convert_to_unix_filename(char *filename) } static RD_BOOL -rdpdr_handle_ok(int device, int handle) +rdpdr_handle_ok(uint32 device, RD_NTHANDLE handle) { switch (g_rdpdr_device[device].device_type) { @@ -234,10 +234,10 @@ rdpdr_send_client_name_request(void) } /* Returns the size of the payload of the announce packet */ -static int +static size_t announcedata_size() { - int size, i; + size_t size, i; PRINTER *printerinfo; DISK_DEVICE *diskinfo; @@ -280,7 +280,7 @@ rdpdr_send_client_device_list_announce(void) { /* DR_CORE_CLIENT_ANNOUNCE_RSP */ uint32 bloblen, disklen, flags; - int i; + size_t i; STREAM s; PRINTER *printerinfo; DISK_DEVICE *diskinfo; @@ -947,7 +947,7 @@ rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, RD_BOOL support for reconnects. */ FD_SET(iorq->fd, rfds); - *n = MAX(*n, iorq->fd); + *n = MAX(*n, (int)iorq->fd); /* Check if io request timeout is smaller than current (but not 0). */ if (iorq->timeout @@ -982,7 +982,7 @@ rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, RD_BOOL break; FD_SET(iorq->fd, wfds); - *n = MAX(*n, iorq->fd); + *n = MAX(*n, (int)iorq->fd); break; case IRP_MJ_DEVICE_CONTROL: diff --git a/rdpsnd_alsa.c b/rdpsnd_alsa.c index f5a0bcd..f68562a 100644 --- a/rdpsnd_alsa.c +++ b/rdpsnd_alsa.c @@ -33,10 +33,10 @@ #define MAX_FRAMES 32 static struct pollfd pfds_out[32]; -static int num_fds_out; +static size_t num_fds_out; static struct pollfd pfds_in[32]; -static int num_fds_in; +static size_t num_fds_in; static snd_pcm_t *out_handle = NULL; static snd_pcm_t *in_handle = NULL; @@ -359,7 +359,7 @@ alsa_play(void) STREAM out; int len; static long prev_s, prev_us; - unsigned int duration; + int duration; struct timeval tv; int next_tick; diff --git a/scard.c b/scard.c index f6c324b..6695fd3 100644 --- a/scard.c +++ b/scard.c @@ -537,7 +537,7 @@ outBufferStart(STREAM out, int length) static void outBufferFinishWithLimit(STREAM out, char *buffer, unsigned int length, unsigned int highLimit) { - int header = (length < 0) ? (0) : ((length > highLimit) ? (highLimit) : (length)); + unsigned int header = (length > highLimit) ? (highLimit) : (length); out_uint32_le(out, header); if (length <= 0) @@ -579,7 +579,7 @@ inString(PMEM_HANDLE * handle, STREAM in, char **destination, SERVER_DWORD dataL if (wide) { - int i; + unsigned int i; in_uint8a(in, buffer, 2 * dataLength); for (i = 0; i < dataLength; i++) if ((buffer[2 * i] < 0) || (buffer[2 * i + 1] != 0)) @@ -613,7 +613,7 @@ outString(STREAM out, char *source, RD_BOOL wide) if (wide) { - int i; + unsigned int i; char *buffer = SC_xmalloc(&lcHandle, Result); for (i = 0; i < dataLength; i++) @@ -1320,7 +1320,7 @@ TS_SCardCancel(STREAM in, STREAM out) static MYPCSC_DWORD TS_SCardLocateCardsByATR(STREAM in, STREAM out, RD_BOOL wide) { - int i, j, k; + unsigned int i, j, k; MYPCSC_DWORD rv; SERVER_SCARDCONTEXT hContext; MYPCSC_SCARDCONTEXT myHContext; @@ -1752,9 +1752,9 @@ TS_SCardStatus(STREAM in, STREAM out, RD_BOOL wide) "TS_SCardStatus(), hcard: 0x%08x [0x%08lx], reader len: %d bytes, atr len: %d bytes", (unsigned) hCard, (unsigned long) myHCard, (int) dwReaderLen, (int) dwAtrLen); - if (dwReaderLen <= 0 || dwReaderLen == SCARD_AUTOALLOCATE || dwReaderLen > SCARD_MAX_MEM) + if (dwReaderLen == 0 || dwReaderLen == (SERVER_DWORD)SCARD_AUTOALLOCATE || dwReaderLen > SCARD_MAX_MEM) dwReaderLen = SCARD_MAX_MEM; - if (dwAtrLen <= 0 || dwAtrLen == SCARD_AUTOALLOCATE || dwAtrLen > SCARD_MAX_MEM) + if (dwAtrLen == 0 || dwAtrLen == (SERVER_DWORD)SCARD_AUTOALLOCATE || dwAtrLen > SCARD_MAX_MEM) dwAtrLen = SCARD_MAX_MEM; #if 1 @@ -1869,7 +1869,7 @@ TS_SCardState(STREAM in, STREAM out) (unsigned) hCard, (unsigned long) myHCard, (int) dwAtrLen); dwReaderLen = SCARD_MAX_MEM; - if (dwAtrLen <= 0 || dwAtrLen == SCARD_AUTOALLOCATE || dwAtrLen > SCARD_MAX_MEM) + if (dwAtrLen <= 0 || dwAtrLen == (SERVER_DWORD)SCARD_AUTOALLOCATE || dwAtrLen > SCARD_MAX_MEM) dwAtrLen = SCARD_MAX_MEM; readerName = SC_xmalloc(&lcHandle, dwReaderLen + 2); @@ -2244,7 +2244,7 @@ TS_SCardControl(STREAM in, STREAM out) #ifdef PCSCLITE_VERSION_NUMBER if (dwControlCode == SCARD_CTL_CODE(3400)) { - int i; + unsigned int i; SERVER_DWORD cc; for (i = 0; i < nBytesReturned / 6; i++) diff --git a/serial.c b/serial.c index 7ad2f74..4500b5b 100644 --- a/serial.c +++ b/serial.c @@ -557,12 +557,12 @@ serial_create(uint32 device_id, uint32 access, uint32 share_mode, uint32 disposi UNUSED(disposition); UNUSED(flags_and_attributes); UNUSED(filename); - RD_NTHANDLE serial_fd; + int serial_fd; SERIAL_DEVICE *pser_inf; pser_inf = (SERIAL_DEVICE *) g_rdpdr_device[device_id].pdevice_data; - serial_fd = open(g_rdpdr_device[device_id].local_path, O_RDWR | O_NOCTTY | O_NONBLOCK); + serial_fd = open(g_rdpdr_device[device_id].local_path, O_RDWR | O_NOCTTY | O_NONBLOCK); if (serial_fd == -1) { logger(Core, Error, "serial_create(), open '%s' failed: %s", diff --git a/stream.c b/stream.c index 4c9b4b0..028cd80 100644 --- a/stream.c +++ b/stream.c @@ -97,7 +97,7 @@ _out_utf16s(STREAM s, size_t maxlength, const char *string) } ibl = strlen(string); - obl = maxlength ? maxlength : s_left(s); + obl = maxlength ? maxlength : (size_t)s_left(s); pin = string; pout = (char *) s->p; @@ -122,8 +122,7 @@ _out_utf16s(STREAM s, size_t maxlength, const char *string) void out_utf16s_padded(STREAM s, const char *string, size_t length, unsigned char pad) { - int i; - size_t bl; + size_t i, bl; bl = _out_utf16s(s, length - 2, string); // append utf16 null termination diff --git a/utils.c b/utils.c index 9d3ae8c..9ff69d2 100644 --- a/utils.c +++ b/utils.c @@ -77,7 +77,8 @@ utils_string_escape(const char *str) char * utils_string_unescape(const char *str) { - char *ns, *ps, *pd, c; + char *ns, *ps, *pd; + unsigned char c; ns = xmalloc(strlen(str) + 1); memcpy(ns, str, strlen(str) + 1); @@ -90,7 +91,7 @@ utils_string_unescape(const char *str) { if (sscanf(ps, "%%%2hhX", &c) == 1) { - pd[0] = c; + pd[0] = (char)c; ps += 3; pd++; continue; diff --git a/xclip.c b/xclip.c index 62a9569..40b3544 100644 --- a/xclip.c +++ b/xclip.c @@ -506,11 +506,11 @@ xclip_probe_selections() void xclip_handle_SelectionNotify(XSelectionEvent * event) { - unsigned long nitems, bytes_left; + unsigned long i, nitems, bytes_left; XWindowAttributes wa; Atom type; Atom *supported_targets; - int res, i, format; + int res, format; uint8 *data = NULL; if (event->property == None) diff --git a/xwin.c b/xwin.c index 515efe2..9452349 100644 --- a/xwin.c +++ b/xwin.c @@ -2973,17 +2973,17 @@ xcursor_stencil(XcursorImage * src, XcursorImage * dst, int dx, int dy, uint32 a assert(src->width == dst->width); assert(src->height == dst->height); - for (y = 0; y < src->height; y++) + for (y = 0; y < (int)src->height; y++) { - for (x = 0; x < src->width; x++) + for (x = 0; x < (int)src->width; x++) { si = y * src->width + x; if (!src->pixels[si]) continue; - if ((y + dy) < 0 || (y + dy) >= dst->height) + if ((y + dy) < 0 || (y + dy) >= (int)dst->height) continue; - if ((x + dx) < 0 || (x + dx) >= dst->width) + if ((x + dx) < 0 || (x + dx) >= (int)dst->width) continue; di = (y + dy) * src->width + (x + dx); dst->pixels[di] = argb; @@ -3006,8 +3006,8 @@ xcursor_merge(XcursorImage * src, XcursorImage * dst) } RD_HCURSOR -ui_create_cursor(unsigned int xhot, unsigned int yhot, int width, - int height, uint8 * andmask, uint8 * xormask, int bpp) +ui_create_cursor(unsigned int xhot, unsigned int yhot, uint32 width, + uint32 height, uint8 * andmask, uint8 * xormask, int bpp) { Cursor cursor; XcursorPixel *out; @@ -3294,7 +3294,7 @@ static uint8 hatch_patterns[] = { void ui_patblt(uint8 opcode, /* dest */ int x, int y, int cx, int cy, - /* brush */ BRUSH * brush, int bgcolour, int fgcolour) + /* brush */ BRUSH * brush, uint32 bgcolour, uint32 fgcolour) { Pixmap fill; uint8 i, ipattern[8]; @@ -3421,7 +3421,7 @@ void ui_triblt(uint8 opcode, /* dest */ int x, int y, int cx, int cy, /* src */ RD_HBITMAP src, int srcx, int srcy, - /* brush */ BRUSH * brush, int bgcolour, int fgcolour) + /* brush */ BRUSH * brush, uint32 bgcolour, uint32 fgcolour) { /* This is potentially difficult to do in general. Until someone comes up with a more efficient way of doing it I am using cases. */ @@ -3469,7 +3469,7 @@ ui_line(uint8 opcode, void ui_rect( /* dest */ int x, int y, int cx, int cy, - /* brush */ int colour) + /* brush */ uint32 colour) { SET_FOREGROUND(colour); FILL_RECTANGLE(x, y, cx, cy); @@ -3479,7 +3479,7 @@ void ui_polygon(uint8 opcode, /* mode */ uint8 fillmode, /* dest */ RD_POINT * point, int npoints, - /* brush */ BRUSH * brush, int bgcolour, int fgcolour) + /* brush */ BRUSH * brush, uint32 bgcolour, uint32 fgcolour) { uint8 style, i, ipattern[8]; Pixmap fill; @@ -3596,7 +3596,7 @@ void ui_ellipse(uint8 opcode, /* mode */ uint8 fillmode, /* dest */ int x, int y, int cx, int cy, - /* brush */ BRUSH * brush, int bgcolour, int fgcolour) + /* brush */ BRUSH * brush, uint32 bgcolour, uint32 fgcolour) { uint8 style, i, ipattern[8]; Pixmap fill; @@ -3683,7 +3683,7 @@ void ui_draw_glyph(int mixmode, /* dest */ int x, int y, int cx, int cy, /* src */ RD_HGLYPH glyph, int srcx, int srcy, - int bgcolour, int fgcolour) + uint32 bgcolour, uint32 fgcolour) { UNUSED(srcx); UNUSED(srcy); @@ -3739,7 +3739,7 @@ void ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, BRUSH * brush, - int bgcolour, int fgcolour, uint8 * text, uint8 length) + uint32 bgcolour, uint32 fgcolour, uint8 * text, uint8 length) { UNUSED(opcode); UNUSED(brush); @@ -4217,7 +4217,7 @@ ui_seamless_destroy_group(unsigned long id, unsigned long flags) void ui_seamless_seticon(unsigned long id, const char *format, int width, int height, int chunk, - const char *data, int chunk_len) + const char *data, size_t chunk_len) { seamless_window *sw; From af08994cfdee643464ad73004a4953fe929c7f62 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Fri, 20 Oct 2017 12:15:38 +0200 Subject: [PATCH 3/6] Fix define default logger subjects --- utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.c b/utils.c index 9ff69d2..b401966 100644 --- a/utils.c +++ b/utils.c @@ -248,7 +248,7 @@ static char *subject[] = { static log_level_t _logger_level = Warning; -#define DEFAULT_LOGGER_SUBJECTS (1 << Core); +#define DEFAULT_LOGGER_SUBJECTS (1 << Core) #define ALL_LOGGER_SUBJECTS \ (1 << GUI) \ From 8c83f8957be91ab6cdc0c1fea1d716f9fc65945c Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Fri, 20 Oct 2017 13:52:13 +0200 Subject: [PATCH 4/6] Fix SCARD_AUTOALLOCATE handling SCARD_AUTOALLOCATE is a define with value -1, which is compared to an uint32. There was some missassumtion of whenever its -1 or 0xffffffff through the code. --- scard.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/scard.c b/scard.c index 6695fd3..766eabf 100644 --- a/scard.c +++ b/scard.c @@ -2028,22 +2028,17 @@ TS_SCardGetAttrib(STREAM in, STREAM out) "TS_SCardGetAttrib(), hcard: 0x%08x [0x%08lx], attrib: 0x%08x (%d bytes)", (unsigned) hCard, (unsigned long) myHCard, (unsigned) dwAttrId, (int) dwAttrLen); - if (dwAttrLen > MAX_BUFFER_SIZE) + pbAttr = NULL; + if (dwAttrLen != (SERVER_DWORD)SCARD_AUTOALLOCATE) + { + if (dwAttrLen > MAX_BUFFER_SIZE) + { dwAttrLen = MAX_BUFFER_SIZE; + } - - if (dwAttrLen > SCARD_AUTOALLOCATE) - pbAttr = NULL; - else if ((dwAttrLen < 0) || (dwAttrLen > SCARD_MAX_MEM)) - { - dwAttrLen = (SERVER_DWORD) SCARD_AUTOALLOCATE; - pbAttr = NULL; - } - else - { - pbAttr = SC_xmalloc(&lcHandle, dwAttrLen); - if (!pbAttr) - return SC_returnNoMemoryError(&lcHandle, in, out); + pbAttr = SC_xmalloc(&lcHandle, dwAttrLen); + if (!pbAttr) + return SC_returnNoMemoryError(&lcHandle, in, out); } attrLen = dwAttrLen; From f0b2b9d69a660e356f4358a35082a87b16640da6 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 23 Oct 2017 08:42:49 +0200 Subject: [PATCH 5/6] Add 'extra' warnings and 'pedantic' to cflags --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4056c7c..8159c4d 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_CANONICAL_HOST AC_PROG_CC if test "$GCC" = yes; then - CFLAGS="$CFLAGS -Wall" + CFLAGS="$CFLAGS -Wall -Wextra -Wpedantic" fi AC_PROG_INSTALL From a2e402556b579c90611994958aa68425873fc02f Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Mon, 23 Oct 2017 16:39:52 +0200 Subject: [PATCH 6/6] Remove pedantic flag --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8159c4d..79bdbfe 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_CANONICAL_HOST AC_PROG_CC if test "$GCC" = yes; then - CFLAGS="$CFLAGS -Wall -Wextra -Wpedantic" + CFLAGS="$CFLAGS -Wall -Wextra" fi AC_PROG_INSTALL