[PATCH 3/9] vnc: use enum for features

Gerd Hoffmann posted 9 patches 4 years, 11 months ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
There is a newer version of this series
[PATCH 3/9] vnc: use enum for features
Posted by Gerd Hoffmann 4 years, 11 months ago
Use an enum for the vnc feature bits.  That way they are enumerated
automatically and we don't have to do that manually when adding or
removing features.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.h | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/ui/vnc.h b/ui/vnc.h
index 4e2637ce6c5c..262fcf179b44 100644
--- a/ui/vnc.h
+++ b/ui/vnc.h
@@ -438,18 +438,20 @@ enum {
  *
  *****************************************************************************/
 
-#define VNC_FEATURE_RESIZE                   0
-#define VNC_FEATURE_HEXTILE                  1
-#define VNC_FEATURE_POINTER_TYPE_CHANGE      2
-#define VNC_FEATURE_WMVI                     3
-#define VNC_FEATURE_TIGHT                    4
-#define VNC_FEATURE_ZLIB                     5
-#define VNC_FEATURE_COPYRECT                 6
-#define VNC_FEATURE_RICH_CURSOR              7
-#define VNC_FEATURE_TIGHT_PNG                8
-#define VNC_FEATURE_ZRLE                     9
-#define VNC_FEATURE_ZYWRLE                  10
-#define VNC_FEATURE_LED_STATE               11
+enum VncFeatures {
+    VNC_FEATURE_RESIZE,
+    VNC_FEATURE_HEXTILE,
+    VNC_FEATURE_POINTER_TYPE_CHANGE,
+    VNC_FEATURE_WMVI,
+    VNC_FEATURE_TIGHT,
+    VNC_FEATURE_ZLIB,
+    VNC_FEATURE_COPYRECT,
+    VNC_FEATURE_RICH_CURSOR,
+    VNC_FEATURE_TIGHT_PNG,
+    VNC_FEATURE_ZRLE,
+    VNC_FEATURE_ZYWRLE,
+    VNC_FEATURE_LED_STATE,
+};
 
 #define VNC_FEATURE_RESIZE_MASK              (1 << VNC_FEATURE_RESIZE)
 #define VNC_FEATURE_HEXTILE_MASK             (1 << VNC_FEATURE_HEXTILE)
-- 
2.27.0


Re: [PATCH 3/9] vnc: use enum for features
Posted by Marc-André Lureau 4 years, 11 months ago
On Thu, Dec 3, 2020 at 3:08 PM Gerd Hoffmann <kraxel@redhat.com> wrote:

> Use an enum for the vnc feature bits.  That way they are enumerated
> automatically and we don't have to do that manually when adding or
> removing features.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

---
>  ui/vnc.h | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/ui/vnc.h b/ui/vnc.h
> index 4e2637ce6c5c..262fcf179b44 100644
> --- a/ui/vnc.h
> +++ b/ui/vnc.h
> @@ -438,18 +438,20 @@ enum {
>   *
>
> *****************************************************************************/
>
> -#define VNC_FEATURE_RESIZE                   0
> -#define VNC_FEATURE_HEXTILE                  1
> -#define VNC_FEATURE_POINTER_TYPE_CHANGE      2
> -#define VNC_FEATURE_WMVI                     3
> -#define VNC_FEATURE_TIGHT                    4
> -#define VNC_FEATURE_ZLIB                     5
> -#define VNC_FEATURE_COPYRECT                 6
> -#define VNC_FEATURE_RICH_CURSOR              7
> -#define VNC_FEATURE_TIGHT_PNG                8
> -#define VNC_FEATURE_ZRLE                     9
> -#define VNC_FEATURE_ZYWRLE                  10
> -#define VNC_FEATURE_LED_STATE               11
> +enum VncFeatures {
> +    VNC_FEATURE_RESIZE,
> +    VNC_FEATURE_HEXTILE,
> +    VNC_FEATURE_POINTER_TYPE_CHANGE,
> +    VNC_FEATURE_WMVI,
> +    VNC_FEATURE_TIGHT,
> +    VNC_FEATURE_ZLIB,
> +    VNC_FEATURE_COPYRECT,
> +    VNC_FEATURE_RICH_CURSOR,
> +    VNC_FEATURE_TIGHT_PNG,
> +    VNC_FEATURE_ZRLE,
> +    VNC_FEATURE_ZYWRLE,
> +    VNC_FEATURE_LED_STATE,
> +};
>
>  #define VNC_FEATURE_RESIZE_MASK              (1 << VNC_FEATURE_RESIZE)
>  #define VNC_FEATURE_HEXTILE_MASK             (1 << VNC_FEATURE_HEXTILE)
> --
> 2.27.0
>
>
>

-- 
Marc-André Lureau