diff --git a/common/base64.c b/common/base64.c index 3fc8a0c110..9ee2197fa0 100644 --- a/common/base64.c +++ b/common/base64.c @@ -54,7 +54,7 @@ #ifdef PLATFORM_IS_ASCII #define CHARMAP_BASE 0x28 #define E_IV E_INVALID /* For table alignment */ -const unsigned char charmap[] = +static const unsigned char charmap[] = { /* 0x28 */ E_IV, E_IV, E_IV, 0x3e, E_IV, E_IV, E_IV, 0x3f, /* 0x30 */ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, diff --git a/common/scancode.c b/common/scancode.c index 2d48db5b77..cfe6a38608 100644 --- a/common/scancode.c +++ b/common/scancode.c @@ -311,7 +311,7 @@ enum settings_index SI_BASE }; -const struct map_settings global_settings[] = +static const struct map_settings global_settings[] = { { // SI_EVDEV @@ -328,7 +328,7 @@ const struct map_settings global_settings[] = }; // Default mapping set is "evdev" -const struct map_settings *settings = &global_settings[SI_EVDEV]; +static const struct map_settings *settings = &global_settings[SI_EVDEV]; /*****************************************************************************/ int diff --git a/configure.ac b/configure.ac index cc98d6d28e..3ac2311d8f 100644 --- a/configure.ac +++ b/configure.ac @@ -235,6 +235,7 @@ AX_APPEND_COMPILE_FLAGS([-Wextra]) AX_APPEND_COMPILE_FLAGS([-Wno-missing-field-initializers]) AX_APPEND_COMPILE_FLAGS([-Wno-unused-parameter]) AX_APPEND_COMPILE_FLAGS([-Wno-sign-compare]) +AX_APPEND_COMPILE_FLAGS([-Wmissing-variable-declarations], ,[-Werror]) AM_COND_IF([LINUX], [AX_APPEND_COMPILE_FLAGS([-Werror])]) # bsd has warnings that have not been fixed yet diff --git a/sesman/chansrv/Makefile.am b/sesman/chansrv/Makefile.am index e53961b440..c07fcfceef 100644 --- a/sesman/chansrv/Makefile.am +++ b/sesman/chansrv/Makefile.am @@ -74,6 +74,7 @@ xrdp_chansrv_SOURCES = \ sound.h \ xcommon.c \ xcommon.h \ + xcommon_x11.h \ input.h \ audin.c \ audin.h diff --git a/sesman/chansrv/audin.c b/sesman/chansrv/audin.c index 2aa5ac0363..cb2f710053 100644 --- a/sesman/chansrv/audin.c +++ b/sesman/chansrv/audin.c @@ -33,6 +33,7 @@ #include "xrdp_constants.h" #include "fifo.h" #include "audin.h" +#include "sound.h" #define MSG_SNDIN_VERSION 1 #define MSG_SNDIN_FORMATS 2 @@ -47,9 +48,6 @@ #define AUDIN_NAME "AUDIO_INPUT" #define AUDIN_FLAGS 1 /* WTS_CHANNEL_OPTION_DYNAMIC */ -extern struct fifo *g_in_fifo; /* in sound.c */ -extern int g_bytes_in_fifo; /* in sound.c */ - struct xr_wave_format_ex { int wFormatTag; diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index c75c4f9e8a..5af9647f77 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -79,7 +79,7 @@ char *g_exec_name; tbus g_exec_event = 0; tbus g_exec_mutex; tbus g_exec_sem; -int g_exec_pid = 0; +static int g_exec_pid = 0; #define ARRAYSIZE(x) (sizeof(x)/sizeof(*(x))) /* max total channel bytes size */ diff --git a/sesman/chansrv/chansrv.h b/sesman/chansrv/chansrv.h index 6e86f73799..8c3cd8041b 100644 --- a/sesman/chansrv/chansrv.h +++ b/sesman/chansrv/chansrv.h @@ -24,6 +24,19 @@ #include "parse.h" #include "log.h" +extern struct config_chansrv *g_cfg; + +extern int g_display_num; +extern int g_cliprdr_chan_id; +extern int g_rdpsnd_chan_id; +extern int g_rdpdr_chan_id; +extern int g_rail_chan_id; + +extern char *g_exec_name; +extern tbus g_exec_event; +extern tbus g_exec_mutex; +extern tbus g_exec_sem; + struct chan_item { int id; diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 937a23eada..226f5e5137 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -16,18 +16,16 @@ * limitations under the License. */ -/* FUSE mount point */ -char g_fuse_root_path[256] = ""; -#ifdef XRDP_FUSE -static const char *g_fuse_root_path_basename; /* See xfuse_path_in_xfuse_fs() */ -static int g_fuse_root_parent_dev; /* Ditto */ -static int g_fuse_root_parent_ino; /* Ditto */ -#endif -char g_fuse_clipboard_path[256] = ""; /* for clipboard use */ - #if defined(HAVE_CONFIG_H) #include #endif +#include "arch.h" +#include "chansrv_fuse.h" +#include "chansrv_xfs.h" + + +// Globals needed regardless of the value of XRDP_FUSE +char g_fuse_clipboard_path[256] = ""; /* for clipboard use */ #ifndef XRDP_FUSE @@ -41,10 +39,6 @@ char g_fuse_clipboard_path[256] = ""; /* for clipboard use */ #include #include -#include "arch.h" -#include "chansrv_fuse.h" -#include "chansrv_xfs.h" - /* dummy calls when XRDP_FUSE is not defined */ int xfuse_init(void) { @@ -162,18 +156,21 @@ int xfuse_path_in_xfuse_fs(const char *path) #include #include -#include "arch.h" #include "os_calls.h" #include "string_calls.h" #include "clipboard_file.h" -#include "chansrv_fuse.h" -#include "chansrv_xfs.h" #include "chansrv.h" #include "chansrv_config.h" #include "devredir.h" #include "list.h" #include "file.h" +/* FUSE mount point */ +static char g_fuse_root_path[256] = ""; +static const char *g_fuse_root_path_basename; /* See xfuse_path_in_xfuse_fs() */ +static int g_fuse_root_parent_dev; /* Ditto */ +static int g_fuse_root_parent_ino; /* Ditto */ + /* Check for FUSE features we may wish to use * * Note that FUSE_VERSION might be more useful for some features than @@ -191,9 +188,6 @@ int xfuse_path_in_xfuse_fs(const char *path) #define XFUSE_ENTRY_TIMEOUT 5.0 -extern struct config_chansrv *g_cfg; /* in chansrv.c */ - - /* Local utility functions */ static inline char * diff --git a/sesman/chansrv/chansrv_fuse.h b/sesman/chansrv/chansrv_fuse.h index ae38356633..754d512fa8 100644 --- a/sesman/chansrv/chansrv_fuse.h +++ b/sesman/chansrv/chansrv_fuse.h @@ -25,6 +25,8 @@ #include "arch.h" #include "ms-erref.h" +extern char g_fuse_clipboard_path[256]; + /* Used to pass file info back to chansrv_fuse from devredir */ struct file_attr { diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index f2fa792c2f..9616576be6 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -184,16 +184,8 @@ x-special/gnome-copied-files #define BMPFILEHEADER_LEN 14 #define BMPINFOHEADER_LEN 40 -extern int g_cliprdr_chan_id; /* in chansrv.c */ - extern Display *g_display; /* in xcommon.c */ -extern int g_x_socket; /* in xcommon.c */ -extern tbus g_x_wait_obj; /* in xcommon.c */ extern Screen *g_screen; /* in xcommon.c */ -extern int g_screen_num; /* in xcommon.c */ - -extern struct config_chansrv *g_cfg; /* in chansrv.c */ - int g_clip_up = 0; static Atom g_clipboard_atom = 0; /* CLIPBOARD */ diff --git a/sesman/chansrv/clipboard.h b/sesman/chansrv/clipboard.h index 62108eb314..2afef9b651 100644 --- a/sesman/chansrv/clipboard.h +++ b/sesman/chansrv/clipboard.h @@ -23,6 +23,11 @@ #include "arch.h" #include "parse.h" +extern int g_clip_up; + +extern struct clip_s2c g_clip_s2c; +extern struct clip_c2s g_clip_c2s; + int clipboard_init(void); int clipboard_deinit(void); int clipboard_data_in(struct stream *s, int chan_id, int chan_flags, int length, int total_length); diff --git a/sesman/chansrv/clipboard_file.c b/sesman/chansrv/clipboard_file.c index 0be2f6e68e..e92c5284d3 100644 --- a/sesman/chansrv/clipboard_file.c +++ b/sesman/chansrv/clipboard_file.c @@ -44,13 +44,6 @@ #include "chansrv_fuse.h" #include "ms-rdpeclip.h" -extern int g_cliprdr_chan_id; /* in chansrv.c */ - -extern struct clip_s2c g_clip_s2c; /* in clipboard.c */ -extern struct clip_c2s g_clip_c2s; /* in clipboard.c */ - -extern char g_fuse_clipboard_path[]; - struct cb_file_info { char *pathname; diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 85574e0df7..adda7cc764 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -100,9 +100,6 @@ enum COMPLETION_TYPE }; -/* globals */ -extern int g_rdpdr_chan_id; /* in chansrv.c */ - /* Capabilities from GENERAL_CAPS_SET in Client Core Capability Response */ struct client_caps { @@ -118,10 +115,10 @@ static struct client_caps g_ccap; tui32 g_completion_id = 1; -tui32 g_clientID; /* unique client ID - announced by client */ -tui32 g_device_id; /* unique device ID - announced by client */ -tui16 g_client_rdp_version; /* returned by client */ -struct stream *g_input_stream = NULL; +static tui32 g_clientID; /* unique client ID - announced by client */ +static tui32 g_device_id; /* unique device ID - announced by client */ +static tui16 g_client_rdp_version; /* returned by client */ +static struct stream *g_input_stream = NULL; /* * Local functions called from devredir_proc_device_iocompletion() diff --git a/sesman/chansrv/devredir.h b/sesman/chansrv/devredir.h index 651cb2a3d2..fc8e2670fa 100644 --- a/sesman/chansrv/devredir.h +++ b/sesman/chansrv/devredir.h @@ -24,6 +24,8 @@ #include "irp.h" #include "ms-rdpefs.h" +extern tui32 g_completion_id; + int devredir_init(void); int devredir_deinit(void); diff --git a/sesman/chansrv/irp.c b/sesman/chansrv/irp.c index a1bf9a4d57..05ec52eb48 100644 --- a/sesman/chansrv/irp.c +++ b/sesman/chansrv/irp.c @@ -31,7 +31,7 @@ #include "string_calls.h" #include "irp.h" -IRP *g_irp_head = NULL; +static IRP *g_irp_head = NULL; /** * Create a new IRP and append to linked list diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index a9bac1a6ff..a3adb02b7d 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -37,28 +37,13 @@ #include "chansrv.h" #include "rail.h" #include "xcommon.h" +#include "xcommon_x11.h" #include "log.h" #include "os_calls.h" #include "string_calls.h" #include "thread_calls.h" #include "list.h" -extern int g_rail_chan_id; /* in chansrv.c */ -extern int g_display_num; /* in chansrv.c */ -extern char *g_exec_name; /* in chansrv.c */ -extern tbus g_exec_event; /* in chansrv.c */ -extern tbus g_exec_mutex; /* in chansrv.c */ -extern tbus g_exec_sem; /* in chansrv.c */ - -extern Display *g_display; /* in xcommon.c */ -extern Screen *g_screen; /* in xcommon.c */ -extern Window g_root_window; /* in xcommon.c */ -extern Atom g_wm_delete_window_atom; /* in xcommon.c */ -extern Atom g_wm_protocols_atom; /* in xcommon.c */ -extern Atom g_utf8_string; /* in xcommon.c */ -extern Atom g_net_wm_name; /* in xcommon.c */ -extern Atom g_wm_state; /* in xcommon.c */ - static Atom g_rwd_atom = 0; int g_rail_up = 0; diff --git a/sesman/chansrv/rail.h b/sesman/chansrv/rail.h index 74dcd20b6b..df26ea88bf 100644 --- a/sesman/chansrv/rail.h +++ b/sesman/chansrv/rail.h @@ -23,6 +23,8 @@ #include "arch.h" #include "parse.h" +extern int g_rail_up; + int rail_init(void); int diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c index 7dd1edd210..c35a9352aa 100644 --- a/sesman/chansrv/smartcard.c +++ b/sesman/chansrv/smartcard.c @@ -124,15 +124,11 @@ typedef struct smartcard } SMARTCARD; /* globals */ -SMARTCARD *smartcards[MAX_SMARTCARDS]; -int g_smartcards_inited = 0; +static SMARTCARD *smartcards[MAX_SMARTCARDS]; +static int g_smartcards_inited = 0; static tui32 g_device_id = 0; static int g_scard_index = 0; -/* externs */ -extern tui32 g_completion_id; -extern int g_rdpdr_chan_id; /* in chansrv.c */ - /****************************************************************************** ** static functions local to this file ** diff --git a/sesman/chansrv/smartcard_pcsc.c b/sesman/chansrv/smartcard_pcsc.c index 0584188141..d459ac4916 100644 --- a/sesman/chansrv/smartcard_pcsc.c +++ b/sesman/chansrv/smartcard_pcsc.c @@ -56,8 +56,6 @@ #if PCSC_STANDIN -extern int g_display_num; /* in chansrv.c */ - static int g_autoinc = 0; /* general purpose autoinc */ struct pcsc_card /* item for list of open cards in one context */ diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c index a67628b775..85c934eec1 100644 --- a/sesman/chansrv/sound.c +++ b/sesman/chansrv/sound.c @@ -62,10 +62,6 @@ static OpusEncoder *g_opus_encoder = 0; static lame_global_flags *g_lame_encoder = 0; #endif -extern int g_rdpsnd_chan_id; /* in chansrv.c */ -extern int g_display_num; /* in chansrv.c */ -extern struct config_chansrv *g_cfg; /* in chansrv.c */ - /* audio out: sound_server -> xrdp -> NeutrinoRDP */ static struct trans *g_audio_l_trans_out = 0; /* listener */ static struct trans *g_audio_c_trans_out = 0; /* connection */ diff --git a/sesman/chansrv/sound.h b/sesman/chansrv/sound.h index 2b846a95d0..188551d2e5 100644 --- a/sesman/chansrv/sound.h +++ b/sesman/chansrv/sound.h @@ -25,6 +25,9 @@ #include "chansrv.h" #include "trans.h" +extern struct fifo *g_in_fifo; +extern int g_bytes_in_fifo; + #define SNDC_CLOSE 0x01 #define SNDC_WAVE 0x02 #define SNDC_SETVOLUME 0x03 diff --git a/sesman/chansrv/xcommon.c b/sesman/chansrv/xcommon.c index 2067bbd6f4..ec2660deb2 100644 --- a/sesman/chansrv/xcommon.c +++ b/sesman/chansrv/xcommon.c @@ -29,23 +29,23 @@ #include "clipboard.h" #include "rail.h" #include "xcommon.h" +#include "xcommon_x11.h" -extern int g_clip_up; /* in clipboard.c */ - -extern int g_rail_up; /* in rail.c */ - +/* globals declared in xcommon_x11.h */ Display *g_display = 0; -int g_x_socket = 0; -tbus g_x_wait_obj = 0; Screen *g_screen = 0; int g_screen_num = 0; -Window g_root_window = 0; Atom g_wm_delete_window_atom = 0; Atom g_wm_protocols_atom = 0; Atom g_utf8_string = 0; Atom g_net_wm_name = 0; Atom g_wm_state = 0; +/* globals declared in xcommon.h */ +int g_x_socket = 0; +tbus g_x_wait_obj = 0; +Window g_root_window = 0; + static x_server_fatal_cb_type x_server_fatal_handler = 0; diff --git a/sesman/chansrv/xcommon.h b/sesman/chansrv/xcommon.h index 3195eda2a9..3351a45b3d 100644 --- a/sesman/chansrv/xcommon.h +++ b/sesman/chansrv/xcommon.h @@ -28,6 +28,15 @@ typedef void (*x_server_fatal_cb_type)(void); +/* + * Global variables defined in xcommon.c + * + * For globals with X11-specific types, see xcommon_x11.h + */ +extern int g_x_socket; +extern tbus g_x_wait_obj; +extern int g_screen_num; + int xcommon_init(void); int diff --git a/sesman/chansrv/xcommon_x11.h b/sesman/chansrv/xcommon_x11.h new file mode 100644 index 0000000000..133842b0d2 --- /dev/null +++ b/sesman/chansrv/xcommon_x11.h @@ -0,0 +1,40 @@ +/** + * xrdp: A Remote Desktop Protocol server. + * + * Copyright (C) Jay Sorg 2012 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file sesman/chansrv/xcommon_vars.c + * + * xcommon global variables + * + * Declares global variables defined in xcommon.h with X11-specific types + */ +#if !defined(XCOMMON_X11_H) +#define XCOMMON_X11_H + +#include + +extern Display *g_display; +extern Screen *g_screen; +extern Window g_root_window; +extern Atom g_wm_delete_window_atom; +extern Atom g_wm_protocols_atom; +extern Atom g_utf8_string; +extern Atom g_net_wm_name; +extern Atom g_wm_state; + +#endif diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c index 18e02335b9..124114b8bd 100644 --- a/sesman/tools/sesadmin.c +++ b/sesman/tools/sesadmin.c @@ -34,8 +34,8 @@ #include -char cmnd[257]; -char port[257]; +static char cmnd[257]; +static char port[257]; static int cmndList(struct trans *t); static int cmndKill(struct trans *t); diff --git a/sesman/tools/xcon.c b/sesman/tools/xcon.c index a16f6e5a55..aceab0dca2 100644 --- a/sesman/tools/xcon.c +++ b/sesman/tools/xcon.c @@ -29,8 +29,8 @@ #include #include -Display *g_display = 0; -int g_x_socket = 0; +static Display *g_display = 0; +static int g_x_socket = 0; int main(int argc, char **argv) { diff --git a/tests/libxrdp/test_xrdp_sec_process_mcs_data_monitors.c b/tests/libxrdp/test_xrdp_sec_process_mcs_data_monitors.c index 27d8342227..2d1a2d449e 100644 --- a/tests/libxrdp/test_xrdp_sec_process_mcs_data_monitors.c +++ b/tests/libxrdp/test_xrdp_sec_process_mcs_data_monitors.c @@ -7,9 +7,9 @@ #include "test_libxrdp.h" -struct xrdp_sec *sec_layer; -struct xrdp_rdp *rdp_layer; -struct xrdp_session *session; +static struct xrdp_sec *sec_layer; +static struct xrdp_rdp *rdp_layer; +static struct xrdp_session *session; static void setup(void) { diff --git a/third_party/copying_third_party.h b/third_party/copying_third_party.h index 1285dbaa6d..b60bff8b90 100644 --- a/third_party/copying_third_party.h +++ b/third_party/copying_third_party.h @@ -1,5 +1,5 @@ #include -const char copying_third_party[] = "\ +static const char copying_third_party[] = "\ -- tomlc99: TOML C library\n\ \n\ MIT License\n\ @@ -27,4 +27,4 @@ SOFTWARE.\n\ \n\ --------------------------------------------------------------------------------\n\ "; -const size_t copying_third_party_len = sizeof(copying_third_party) - 1; +static const size_t copying_third_party_len = sizeof(copying_third_party) - 1; diff --git a/tools/devel/tcp_proxy/main.c b/tools/devel/tcp_proxy/main.c index 9d1c7f38cd..3976b861f2 100644 --- a/tools/devel/tcp_proxy/main.c +++ b/tools/devel/tcp_proxy/main.c @@ -39,8 +39,8 @@ #include "os_calls.h" #include "string_calls.h" -int g_loc_io_count = 0; // bytes read from local port -int g_rem_io_count = 0; // bytes read from remote port +static int g_loc_io_count = 0; // bytes read from local port +static int g_rem_io_count = 0; // bytes read from remote port static int g_terminated = 0; diff --git a/xrdp/lang.c b/xrdp/lang.c index a5ef2f476c..fb7562c935 100644 --- a/xrdp/lang.c +++ b/xrdp/lang.c @@ -46,7 +46,7 @@ struct km_general int caps_lock_supported; }; -const struct km_general km_general_default = +static const struct km_general km_general_default = { .version = 0, .caps_lock_supported = 1 diff --git a/xrdp_accel_assist/xrdp_accel_assist_x11.c b/xrdp_accel_assist/xrdp_accel_assist_x11.c index 3c1b41f4a9..020cd135cc 100644 --- a/xrdp_accel_assist/xrdp_accel_assist_x11.c +++ b/xrdp_accel_assist/xrdp_accel_assist_x11.c @@ -59,7 +59,7 @@ /* X11 */ Display *g_display = NULL; -static int g_x_socket = 0; +int g_x_socket = 0; int g_screen_num = 0; static Screen *g_screen = NULL; Window g_root_window = None;