[Spice-devel] [PATCH 12/16] Mark unused public API methods/code as deprecated

Jonathon Jongsma jjongsma at redhat.com
Tue Apr 19 21:22:28 UTC 2016


On Tue, 2016-04-19 at 11:00 -0500, Jonathon Jongsma wrote:
> From: Christophe Fergeau <cfergeau at redhat.com>
> 
> Also mark one probably unused code block with a g_critical()
> ---
>  server/display-channel.c |  3 +++
>  server/sound.c           |  1 +
>  server/spice-migration.h |  6 +++---
>  server/spice-server.h    | 12 +++++++-----
>  4 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/server/display-channel.c b/server/display-channel.c
> index 74cc357..5d1662e 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -1923,6 +1923,9 @@ void display_channel_create_surface(DisplayChannel
> *display, uint32_t surface_id
>          QXLInstance *qxl = display->common.qxl;
>          RedsState *reds = red_qxl_get_server(qxl->st);
>          GArray *renderers = reds_get_renderers(reds);
> +        /* These days, noone is trying to use multiple renderers, the
> software one
> +         * is always used */
> +        g_warn_if_fail(renderers->len == 1);
>          for (i = 0; i < renderers->len; i++) {
>              uint32_t renderer = g_array_index(renderers, uint32_t, i);
>              surface->context.canvas = create_canvas_for_surface(display,
> surface, renderer);
> diff --git a/server/sound.c b/server/sound.c
> index 46f2cb1..453e42a 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -1620,6 +1620,7 @@ void snd_set_playback_compression(int on)
>      playback_compression = !!on;
>  
>      for (; now; now = now->next) {
> +        g_critical("untested code path");

I'm not sure I agree with this. In practice, this will result in the server
aborting. I think that if we think it's untested enough that we'd rather abort
than run the code, perhaps we should just remove this code...?

Also, I think that the deprecation changes should probably be separate from the
warning changes above.

>          if (now->base_channel->type == SPICE_CHANNEL_PLAYBACK && now
> ->connection) {
>              PlaybackChannel* playback = (PlaybackChannel*)now->connection;
>              SpicePlaybackState *st = SPICE_CONTAINEROF(now,
> SpicePlaybackState, worker);
> diff --git a/server/spice-migration.h b/server/spice-migration.h
> index 51c6444..944e133 100644
> --- a/server/spice-migration.h
> +++ b/server/spice-migration.h
> @@ -46,8 +46,8 @@ struct SpiceMigrateInstance {
>  /* spice switch-host client migration */
>  int spice_server_migrate_info(SpiceServer *s, const char* dest,
>                                int port, int secure_port,
> -                              const char* cert_subject);
> -int spice_server_migrate_switch(SpiceServer *s);
> +                              const char* cert_subject) G_GNUC_DEPRECATED;
> +int spice_server_migrate_switch(SpiceServer *s) G_GNUC_DEPRECATED;
>  
>  /* spice (semi-)seamless client migration */
>  int spice_server_migrate_connect(SpiceServer *s, const char* dest,
> @@ -56,6 +56,6 @@ int spice_server_migrate_connect(SpiceServer *s, const char*
> dest,
>  int spice_server_migrate_start(SpiceServer *s);
>  int spice_server_migrate_end(SpiceServer *s, int completed);
>  
> -void spice_server_set_seamless_migration(SpiceServer *s, int enable);
> +void spice_server_set_seamless_migration(SpiceServer *s, int enable)
> G_GNUC_DEPRECATED;
>  
>  #endif /* SPICE_MIGRATION_H_ */
> diff --git a/server/spice-server.h b/server/spice-server.h
> index c2ff61d..d309f18 100644
> --- a/server/spice-server.h
> +++ b/server/spice-server.h
> @@ -22,6 +22,8 @@
>  #error "Only spice.h can be included directly."
>  #endif
>  
> +#include <glib.h>
> +
>  #include "spice-core.h"
>  
>  /* Don't use features incompatible with a specific spice
> @@ -48,7 +50,7 @@ int spice_server_set_compat_version(SpiceServer *s,
>                                      spice_compat_version_t version);
>  int spice_server_set_port(SpiceServer *s, int port);
>  void spice_server_set_addr(SpiceServer *s, const char *addr, int flags);
> -int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd);
> +int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd)
> G_GNUC_DEPRECATED;
>  int spice_server_set_exit_on_disconnect(SpiceServer *s, int flag);
>  int spice_server_set_noauth(SpiceServer *s);
>  int spice_server_set_sasl(SpiceServer *s, int enabled);
> @@ -97,7 +99,7 @@ int spice_server_set_zlib_glz_compression(SpiceServer *s,
> spice_wan_compression_
>  
>  int spice_server_set_channel_security(SpiceServer *s, const char *channel,
> int security);
>  
> -int spice_server_add_renderer(SpiceServer *s, const char *name);
> +int spice_server_add_renderer(SpiceServer *s, const char *name)
> G_GNUC_DEPRECATED;
>  
>  enum {
>      SPICE_STREAM_VIDEO_INVALID,
> @@ -112,8 +114,8 @@ int spice_server_set_agent_mouse(SpiceServer *s, int
> enable);
>  int spice_server_set_agent_copypaste(SpiceServer *s, int enable);
>  int spice_server_set_agent_file_xfer(SpiceServer *s, int enable);
>  
> -int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t
> *salen);
> -int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t
> *salen);
> +int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t
> *salen) G_GNUC_DEPRECATED;
> +int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t
> *salen) G_GNUC_DEPRECATED;
>  
>  int spice_server_is_server_mouse(SpiceServer *s);
>  
> @@ -123,6 +125,6 @@ void spice_server_set_uuid(SpiceServer *s, const uint8_t
> uuid[16]);
>  void spice_server_vm_start(SpiceServer *s);
>  void spice_server_vm_stop(SpiceServer *s);
>  
> -int spice_server_get_num_clients(SpiceServer *s);
> +int spice_server_get_num_clients(SpiceServer *s) G_GNUC_DEPRECATED;
>  
>  #endif /* SPICE_SERVER_H_ */


Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com>


More information about the Spice-devel mailing list