From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Daniel P. Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [PATCH] ui: drop VNC feature _MASK constants
Date: Wed, 3 Jan 2024 14:26:41 +0100 [thread overview]
Message-ID: <a81a9bb0-4d5b-40bb-b6b2-87c70ba23743@linaro.org> (raw)
In-Reply-To: <20240103122600.2399662-1-berrange@redhat.com>
On 3/1/24 13:26, Daniel P. Berrangé wrote:
> Each VNC feature enum entry has a corresponding _MASK constant
> which is the bit-shifted value. It is very easy for contributors
> to accidentally use the _MASK constant, instead of the non-_MASK
> constant, or the reverse. No compiler warning is possible and
> it'll just silently do the wrong thing at runtime.
>
> By introducing the vnc_set_feature helper method, we can drop
> all the _MASK constants and thus prevent any future accidents.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> ui/vnc.c | 34 +++++++++++++++++-----------------
> ui/vnc.h | 21 ++++-----------------
> 2 files changed, 21 insertions(+), 34 deletions(-)
> @@ -599,6 +582,10 @@ static inline uint32_t vnc_has_feature(VncState *vs, int feature) {
> return (vs->features & (1 << feature));
> }
>
> +static inline void vnc_set_feature(VncState *vs, int feature) {
Even stricter using s/int/VncFeatures/ enum type.
With that:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> + vs->features |= (1 << feature);
> +}
next prev parent reply other threads:[~2024-01-03 13:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-03 12:26 [PATCH] ui: drop VNC feature _MASK constants Daniel P. Berrangé
2024-01-03 13:26 ` Philippe Mathieu-Daudé [this message]
2024-01-03 13:57 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a81a9bb0-4d5b-40bb-b6b2-87c70ba23743@linaro.org \
--to=philmd@linaro.org \
--cc=berrange@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).