[Spice-devel] [spice-server v2] Make various functions static

Frediano Ziglio fziglio at redhat.com
Wed Mar 1 11:06:51 UTC 2017


> 
> - glz_enc_dictionary_reset
> - monitors_config_new
> - red_channel_any_blocked
> - red_channel_no_item_being_sent
> - red_client_get_channel
> - reds_stream_write
> 
> are only used in the file where they are defined, so they can as well be
> static.
> 

I have a script that tells you the unused and the ones you could make
static. I didn't expect you cleaned all up! :)

Do you want the list of unused?

> Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
> ---
>  server/display-channel.c  | 2 +-
>  server/display-channel.h  | 2 --
>  server/glz-encoder-dict.c | 5 ++++-
>  server/glz-encoder-dict.h | 3 ---
>  server/red-channel.c      | 5 +++--
>  server/red-channel.h      | 5 -----
>  server/red-client.c       | 2 +-
>  server/red-client.h       | 1 -
>  server/reds-stream.c      | 4 +++-
>  server/reds-stream.h      | 1 -
>  10 files changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/server/display-channel.c b/server/display-channel.c
> index aa71ba4..da9a78f 100644
> --- a/server/display-channel.c
> +++ b/server/display-channel.c
> @@ -150,7 +150,7 @@ static void monitors_config_debug(MonitorsConfig *mc)
>                      mc->heads[i].width, mc->heads[i].height);
>  }
>  
> -MonitorsConfig* monitors_config_new(QXLHead *heads, ssize_t nheads, ssize_t
> max)
> +static MonitorsConfig* monitors_config_new(QXLHead *heads, ssize_t nheads,
> ssize_t max)
>  {
>      MonitorsConfig *mc;
>  
> diff --git a/server/display-channel.h b/server/display-channel.h
> index 3d4accf..5604fc5 100644
> --- a/server/display-channel.h
> +++ b/server/display-channel.h
> @@ -140,8 +140,6 @@ typedef struct RedMonitorsConfigItem {
>      MonitorsConfig *monitors_config;
>  } RedMonitorsConfigItem;
>  
> -MonitorsConfig*            monitors_config_new
> (QXLHead *heads, ssize_t nheads,
> -
> ssize_t
> max);
>  MonitorsConfig *           monitors_config_ref
>  (MonitorsConfig *config);
>  void                       monitors_config_unref
>  (MonitorsConfig *config);
>  
> diff --git a/server/glz-encoder-dict.c b/server/glz-encoder-dict.c
> index af74736..b96eaec 100644
> --- a/server/glz-encoder-dict.c
> +++ b/server/glz-encoder-dict.c
> @@ -26,6 +26,8 @@
>  #include "glz-encoder-dict.h"
>  #include "glz-encoder-priv.h"
>  
> +static void glz_enc_dictionary_reset(GlzEncDictContext *opaque_dict,
> GlzEncoderUsrContext *usr);
> +
>  /* turning all used images to free ones. If they are alive, calling the
>  free_image callback for
>     each one */
>  static inline void __glz_dictionary_window_reset_images(SharedDictionary
>  *dict)
> @@ -201,7 +203,8 @@ GlzEncDictContext
> *glz_enc_dictionary_restore(GlzEncDictRestoreData *restore_dat
>      return ((GlzEncDictContext *)ret);
>  }
>  
> -void glz_enc_dictionary_reset(GlzEncDictContext *opaque_dict,
> GlzEncoderUsrContext *usr)
> +/*  NOTE - you should use this routine only when no encoder uses the
> dictionary. */
> +static void glz_enc_dictionary_reset(GlzEncDictContext *opaque_dict,
> GlzEncoderUsrContext *usr)
>  {
>      SharedDictionary *dict = (SharedDictionary *)opaque_dict;
>      dict->cur_usr = usr;
> diff --git a/server/glz-encoder-dict.h b/server/glz-encoder-dict.h
> index 79b3781..4cbb80f 100644
> --- a/server/glz-encoder-dict.h
> +++ b/server/glz-encoder-dict.h
> @@ -60,9 +60,6 @@ void glz_enc_dictionary_get_restore_data(GlzEncDictContext
> *opaque_dict,
>  GlzEncDictContext *glz_enc_dictionary_restore(GlzEncDictRestoreData
>  *restore_data,
>                                                GlzEncoderUsrContext *usr);
>  
> -/*  NOTE - you should use this routine only when no encoder uses the
> dictionary. */
> -void glz_enc_dictionary_reset(GlzEncDictContext *opaque_dict,
> GlzEncoderUsrContext *usr);
> -
>  /* image: the context returned by the encoder when the image was encoded.
>     NOTE - you should use this routine only when no encoder uses the
>     dictionary.*/
>  void glz_enc_dictionary_remove_image(GlzEncDictContext *opaque_dict,
> diff --git a/server/red-channel.c b/server/red-channel.c
> index 67a570d..1587766 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -556,7 +556,8 @@ int red_channel_all_blocked(RedChannel *channel)
>      return TRUE;
>  }
>  
> -int red_channel_any_blocked(RedChannel *channel)
> +/* return TRUE if any of the connected clients to this channel are blocked
> */
> +static int red_channel_any_blocked(RedChannel *channel)
>  {
>      GListIter iter;
>      RedChannelClient *rcc;
> @@ -569,7 +570,7 @@ int red_channel_any_blocked(RedChannel *channel)
>      return FALSE;
>  }
>  
> -int red_channel_no_item_being_sent(RedChannel *channel)
> +static int red_channel_no_item_being_sent(RedChannel *channel)
>  {
>      GListIter iter;
>      RedChannelClient *rcc;
> diff --git a/server/red-channel.h b/server/red-channel.h
> index 79aee01..59291d0 100644
> --- a/server/red-channel.h
> +++ b/server/red-channel.h
> @@ -192,11 +192,6 @@ void red_channel_pipes_add_empty_msg(RedChannel
> *channel, int msg_type);
>  /* return TRUE if all of the connected clients to this channel are blocked
>  */
>  int red_channel_all_blocked(RedChannel *channel);
>  
> -/* return TRUE if any of the connected clients to this channel are blocked
> */
> -int red_channel_any_blocked(RedChannel *channel);
> -
> -int red_channel_no_item_being_sent(RedChannel *channel);
> -
>  // TODO: unstaticed for display/cursor channels. they do some specific
>  pushes not through
>  // adding elements or on events. but not sure if this is actually required
>  (only result
>  // should be that they ""try"" a little harder, but if the event system is
>  correct it
> diff --git a/server/red-client.c b/server/red-client.c
> index 2918911..264f1c9 100644
> --- a/server/red-client.c
> +++ b/server/red-client.c
> @@ -226,7 +226,7 @@ void red_client_destroy(RedClient *client)
>  
>  
>  /* client->lock should be locked */
> -RedChannelClient *red_client_get_channel(RedClient *client, int type, int
> id)
> +static RedChannelClient *red_client_get_channel(RedClient *client, int type,
> int id)
>  {
>      GListIter iter;
>      RedChannelClient *rcc;
> diff --git a/server/red-client.h b/server/red-client.h
> index d7e9cc7..121665a 100644
> --- a/server/red-client.h
> +++ b/server/red-client.h
> @@ -48,7 +48,6 @@ void red_client_destroy(RedClient *client);
>  
>  gboolean red_client_add_channel(RedClient *client, RedChannelClient *rcc,
>  GError **error);
>  void red_client_remove_channel(RedChannelClient *rcc);
> -RedChannelClient *red_client_get_channel(RedClient *client, int type, int
> id);
>  
>  MainChannelClient *red_client_get_main(RedClient *client);
>  // main should be set once before all the other channels are created

Not sure if this can helpful... but can be made public if needed,
I don't think is something secret.

> diff --git a/server/reds-stream.c b/server/reds-stream.c
> index 471989e..15b93d3 100644
> --- a/server/reds-stream.c
> +++ b/server/reds-stream.c
> @@ -99,6 +99,8 @@ struct RedsStreamPrivate {
>      RedsState *reds;
>  };
>  
> +static ssize_t reds_stream_write(RedsStream *s, const void *buf, size_t
> nbyte);
> +
>  static ssize_t stream_write_cb(RedsStream *s, const void *buf, size_t size)
>  {
>      return write(s->socket, buf, size);
> @@ -214,7 +216,7 @@ bool reds_stream_write_all(RedsStream *stream, const void
> *in_buf, size_t n)
>  static ssize_t reds_stream_sasl_write(RedsStream *s, const void *buf, size_t
>  nbyte);
>  #endif
>  
> -ssize_t reds_stream_write(RedsStream *s, const void *buf, size_t nbyte)
> +static ssize_t reds_stream_write(RedsStream *s, const void *buf, size_t
> nbyte)
>  {
>      ssize_t ret;
>  
> diff --git a/server/reds-stream.h b/server/reds-stream.h
> index a8d1736..d725672 100644
> --- a/server/reds-stream.h
> +++ b/server/reds-stream.h
> @@ -55,7 +55,6 @@ void reds_stream_async_read(RedsStream *stream, uint8_t
> *data, size_t size,
>                              AsyncReadDone read_done_cb, void *opaque);
>  void reds_stream_set_async_error_handler(RedsStream *stream,
>                                           AsyncReadError error_handler);
> -ssize_t reds_stream_write(RedsStream *s, const void *buf, size_t nbyte);
>  ssize_t reds_stream_writev(RedsStream *s, const struct iovec *iov, int
>  iovcnt);

I think having a write and writev is fine looking at design.

>  bool reds_stream_write_all(RedsStream *stream, const void *in_buf, size_t
>  n);
>  bool reds_stream_write_u8(RedsStream *s, uint8_t n);

About monitors_config_new I don't have a clear idea.
About reds_stream_write I would keep for design consistency.
The others make sense to me.

Frediano


More information about the Spice-devel mailing list