[Spice-devel] [PATCH spice-server] utils: Check we list all channel names
Victor Toso
victortoso at redhat.com
Thu Nov 9 09:04:22 UTC 2017
Hi,
On Wed, Nov 08, 2017 at 04:33:24PM +0000, Frediano Ziglio wrote:
> This prevent future problems supporting new channels.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
> ---
> server/utils.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> Christophe, is this addressing the problem you were thinking?
>
> diff --git a/server/utils.c b/server/utils.c
> index ff1fc2d1..746132e5 100644
> --- a/server/utils.c
> +++ b/server/utils.c
> @@ -20,6 +20,8 @@
>
> #include <glib.h>
> #include <spice/enums.h>
> +#include <common/macros.h>
> +
> #include "utils.h"
>
> int rgb32_data_has_alpha(int width, int height, size_t stride,
> @@ -65,6 +67,14 @@ static const char *const channel_names[] = {
> [ SPICE_CHANNEL_WEBDAV ] = "webdav",
> };
>
> +/* Make sure the last channel in the protocol has a name.
> + * We don't want to do this check in all cases as this would make code
> + * fail to compile if there are additional channels in the protocol so
> + * do this check only if ENABLE_EXTRA_CHECKS is enabled */
> +#if ENABLE_EXTRA_CHECKS
> +verify(G_N_ELEMENTS(channel_names) == SPICE_END_CHANNEL);
> +#endif
> +
> /**
> * red_channel_type_to_str:
> *
> --
> 2.13.6
>
> _______________________________________________
> 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/20171109/47298d08/attachment.sig>
More information about the Spice-devel
mailing list