[Spice-commits] 2 commits - configure.ac server/event-loop.c server/red-common.h server/reds.c server/spice-char.h server/tests
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Jun 29 07:10:26 UTC 2016
configure.ac | 1 +
server/event-loop.c | 6 +++---
server/red-common.h | 2 +-
server/reds.c | 4 ++--
server/spice-char.h | 1 +
server/tests/basic_event_loop.c | 20 +++++++++++---------
6 files changed, 19 insertions(+), 15 deletions(-)
New commits:
commit 3b2fd86e8a0c62f58bb8f82ec72d1987706e978a
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Jun 24 07:38:10 2016 +0100
Constify spice_server_char_device_recognized_subtypes
Users should not change the list of supported subtypes.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/configure.ac b/configure.ac
index 375d26e..4923b40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,6 +11,7 @@ AC_PREREQ([2.57])
# - If any interfaces have been removed or changed since the last public release,
# then set age to 0.
#
+dnl TODO see server/spice-char.h TODO comment for API breakage
m4_define([SPICE_CURRENT], [12])
m4_define([SPICE_REVISION], [0])
m4_define([SPICE_AGE], [11])
diff --git a/server/reds.c b/server/reds.c
index fdf62e5..56138e1 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3161,7 +3161,7 @@ SPICE_GNUC_VISIBLE void spice_server_char_device_wakeup(SpiceCharDeviceInstance*
#define SUBTYPE_USBREDIR "usbredir"
#define SUBTYPE_PORT "port"
-static const char *spice_server_char_device_recognized_subtypes_list[] = {
+static const char *const spice_server_char_device_recognized_subtypes_list[] = {
SUBTYPE_VDAGENT,
#ifdef USE_SMARTCARD
SUBTYPE_SMARTCARD,
@@ -3172,7 +3172,7 @@ static const char *spice_server_char_device_recognized_subtypes_list[] = {
SPICE_GNUC_VISIBLE const char** spice_server_char_device_recognized_subtypes(void)
{
- return spice_server_char_device_recognized_subtypes_list;
+ return (const char **) spice_server_char_device_recognized_subtypes_list;
}
static void reds_add_char_device(RedsState *reds, RedCharDevice *dev)
diff --git a/server/spice-char.h b/server/spice-char.h
index efd685d..1a8a031 100644
--- a/server/spice-char.h
+++ b/server/spice-char.h
@@ -56,6 +56,7 @@ struct SpiceCharDeviceInstance {
void spice_server_char_device_wakeup(SpiceCharDeviceInstance *sin);
void spice_server_port_event(SpiceCharDeviceInstance *char_device, uint8_t event);
+/* TODO change return to const char *const * when API break */
const char** spice_server_char_device_recognized_subtypes(void);
#endif /* SPICE_CHAR_H_ */
commit c70b2067a9eaa67e8c6cd22e5847460cddec504c
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Fri Jun 24 08:22:12 2016 +0100
Constify event_loop_core
Was used as write variable only for testing.
Avoid usage of not constant globals.
Making globals constants avoid future race condition
usages.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
diff --git a/server/event-loop.c b/server/event-loop.c
index 4738ed9..1b57460 100644
--- a/server/event-loop.c
+++ b/server/event-loop.c
@@ -17,9 +17,9 @@
*/
/*
- *This file export a global variable:
+ * This file exports a global variable:
*
- * SpiceCoreInterfaceInternal event_loop_core;
+ * const SpiceCoreInterfaceInternal event_loop_core;
*/
#include "red-common.h"
@@ -168,7 +168,7 @@ static void watch_remove(SpiceWatch *watch)
free(watch);
}
-SpiceCoreInterfaceInternal event_loop_core = {
+const SpiceCoreInterfaceInternal event_loop_core = {
.timer_add = timer_add,
.timer_start = timer_start,
.timer_cancel = timer_cancel,
diff --git a/server/red-common.h b/server/red-common.h
index 7add3d0..7ab7e15 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -58,7 +58,7 @@ struct SpiceCoreInterfaceInternal {
GMainContext *main_context;
};
-extern SpiceCoreInterfaceInternal event_loop_core;
+extern const SpiceCoreInterfaceInternal event_loop_core;
typedef struct RedsState RedsState;
diff --git a/server/tests/basic_event_loop.c b/server/tests/basic_event_loop.c
index b9e1b9c..4820387 100644
--- a/server/tests/basic_event_loop.c
+++ b/server/tests/basic_event_loop.c
@@ -36,6 +36,7 @@ int debug = 0;
} \
}
+static SpiceCoreInterfaceInternal base_core_interface;
static GMainContext *main_context = NULL;
GMainContext *basic_event_loop_get_context(void)
@@ -69,12 +70,12 @@ static void ignore_sigpipe(void)
static SpiceTimer* base_timer_add(SpiceTimerFunc func, void *opaque)
{
- return event_loop_core.timer_add(&event_loop_core, func, opaque);
+ return base_core_interface.timer_add(&base_core_interface, func, opaque);
}
static SpiceWatch *base_watch_add(int fd, int event_mask, SpiceWatchFunc func, void *opaque)
{
- return event_loop_core.watch_add(&event_loop_core, fd, event_mask, func, opaque);
+ return base_core_interface.watch_add(&base_core_interface, fd, event_mask, func, opaque);
}
static SpiceCoreInterface core = {
@@ -91,13 +92,14 @@ SpiceCoreInterface *basic_event_loop_init(void)
ignore_sigpipe();
spice_assert(main_context == NULL);
main_context = g_main_context_new();
- core.timer_start = event_loop_core.timer_start;
- core.timer_cancel = event_loop_core.timer_cancel;
- core.timer_remove = event_loop_core.timer_remove;
- core.watch_update_mask = event_loop_core.watch_update_mask;
- core.watch_remove = event_loop_core.watch_remove;
- event_loop_core.channel_event = core.channel_event = event_loop_channel_event;
- event_loop_core.main_context = main_context;
+ base_core_interface = event_loop_core;
+ core.timer_start = base_core_interface.timer_start;
+ core.timer_cancel = base_core_interface.timer_cancel;
+ core.timer_remove = base_core_interface.timer_remove;
+ core.watch_update_mask = base_core_interface.watch_update_mask;
+ core.watch_remove = base_core_interface.watch_remove;
+ base_core_interface.channel_event = core.channel_event = event_loop_channel_event;
+ base_core_interface.main_context = main_context;
return &core;
}
More information about the Spice-commits
mailing list