[Spice-devel] [PATCH spice-server 3/5] reds: Assume error if RedStreamSslStatus is not recognized

Christophe Fergeau cfergeau at redhat.com
Tue Oct 9 11:42:58 UTC 2018


On Tue, Oct 09, 2018 at 09:30:04AM +0100, Frediano Ziglio wrote:
> Make code safer in case the enumeration is extended in the future.

Without default:, the compiler should give you a compile-time warning
that you don't handle all cases. With default:, the warning is going to
be silenced, and we won't be able to catch this early. So I would not
add it.

Christophe

> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/reds.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/server/reds.c b/server/reds.c
> index ec9f9258..5c2e8cb0 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -2357,6 +2357,7 @@ static void reds_handle_ssl_accept(int fd, int event, void *data)
>      RedStreamSslStatus return_code = red_stream_ssl_accept(link->stream);
>  
>      switch (return_code) {
> +        default:
>          case RED_STREAM_SSL_STATUS_ERROR:
>              reds_link_free(link);
>              return;
> @@ -2422,6 +2423,7 @@ static RedLinkInfo *reds_init_client_ssl_connection(RedsState *reds, int socket)
>          case RED_STREAM_SSL_STATUS_OK:
>              reds_handle_new_link(link);
>              return link;
> +        default:
>          case RED_STREAM_SSL_STATUS_ERROR:
>              goto error;
>          case RED_STREAM_SSL_STATUS_WAIT_FOR_READ:
> -- 
> 2.17.1
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20181009/be8cb74b/attachment.sig>


More information about the Spice-devel mailing list