* [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members
@ 2012-02-25 13:35 Stefan Weil
2012-03-05 13:15 ` Stefan Hajnoczi
2012-03-08 15:26 ` Stefan Hajnoczi
0 siblings, 2 replies; 6+ messages in thread
From: Stefan Weil @ 2012-02-25 13:35 UTC (permalink / raw)
To: QEMU Trivial; +Cc: Stefan Weil, Anthony Liguori, qemu-devel
This patch fixes warnings reported by splint:
For variables which are packed in a single bit, a signed data type
like 'int' does not make much sense.
There is no obvious reason why the two values should be packed,
so I removed the packing and changed the data type to bool
because both are used as boolean values.
Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
ui/vnc-auth-sasl.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ui/vnc-auth-sasl.h b/ui/vnc-auth-sasl.h
index fd9b18a..ee243a9 100644
--- a/ui/vnc-auth-sasl.h
+++ b/ui/vnc-auth-sasl.h
@@ -37,9 +37,9 @@ typedef struct VncDisplaySASL VncDisplaySASL;
struct VncStateSASL {
sasl_conn_t *conn;
/* If we want to negotiate an SSF layer with client */
- int wantSSF :1;
+ bool wantSSF;
/* If we are now running the SSF layer */
- int runSSF :1;
+ bool runSSF;
/*
* If this is non-zero, then wait for that many bytes
* to be written plain, before switching to SSF encoding
--
1.7.9
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members
2012-02-25 13:35 [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members Stefan Weil
@ 2012-03-05 13:15 ` Stefan Hajnoczi
2012-03-08 15:26 ` Stefan Hajnoczi
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2012-03-05 13:15 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Trivial, Anthony Liguori, qemu-devel
On Sat, Feb 25, 2012 at 02:35:47PM +0100, Stefan Weil wrote:
> This patch fixes warnings reported by splint:
>
> For variables which are packed in a single bit, a signed data type
> like 'int' does not make much sense.
>
> There is no obvious reason why the two values should be packed,
> so I removed the packing and changed the data type to bool
> because both are used as boolean values.
>
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
> ui/vnc-auth-sasl.h | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members
2012-02-25 13:35 [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members Stefan Weil
2012-03-05 13:15 ` Stefan Hajnoczi
@ 2012-03-08 15:26 ` Stefan Hajnoczi
2012-03-08 16:08 ` Paolo Bonzini
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Hajnoczi @ 2012-03-08 15:26 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Trivial, Anthony Liguori, qemu-devel
On Sat, Feb 25, 2012 at 1:35 PM, Stefan Weil <sw@weilnetz.de> wrote:
> This patch fixes warnings reported by splint:
>
> For variables which are packed in a single bit, a signed data type
> like 'int' does not make much sense.
>
> There is no obvious reason why the two values should be packed,
> so I removed the packing and changed the data type to bool
> because both are used as boolean values.
>
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
> ui/vnc-auth-sasl.h | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ui/vnc-auth-sasl.h b/ui/vnc-auth-sasl.h
> index fd9b18a..ee243a9 100644
> --- a/ui/vnc-auth-sasl.h
> +++ b/ui/vnc-auth-sasl.h
> @@ -37,9 +37,9 @@ typedef struct VncDisplaySASL VncDisplaySASL;
> struct VncStateSASL {
> sasl_conn_t *conn;
> /* If we want to negotiate an SSF layer with client */
> - int wantSSF :1;
> + bool wantSSF;
> /* If we are now running the SSF layer */
> - int runSSF :1;
> + bool runSSF;
I had to drop this patch from the trivial patches tree, it tickles a
new gcc warning. Please resend with the necessary change.
I cannot reproduce it on my build host here with gcc Debian 4.6.2-12
but Anthony reports the following Ubuntu/Linaro 4.5.2-8ubuntu4:
CC ui/vnc-auth-sasl.o
cc1: warnings being treated as errors
/home/anthony/git/qemu/ui/vnc-auth-sasl.c: In function
‘vnc_sasl_client_cleanup’:
/home/anthony/git/qemu/ui/vnc-auth-sasl.c:34:9: error: suggest
parentheses around assignment used as truth value
make: *** [ui/vnc-auth-sasl.o] Error 1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members
2012-03-08 15:26 ` Stefan Hajnoczi
@ 2012-03-08 16:08 ` Paolo Bonzini
2012-03-08 16:25 ` Anthony Liguori
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2012-03-08 16:08 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: QEMU Trivial, Stefan Weil, Anthony Liguori, qemu-devel
Il 08/03/2012 16:26, Stefan Hajnoczi ha scritto:
> I had to drop this patch from the trivial patches tree, it tickles a
> new gcc warning. Please resend with the necessary change.
>
> I cannot reproduce it on my build host here with gcc Debian 4.6.2-12
> but Anthony reports the following Ubuntu/Linaro 4.5.2-8ubuntu4:
>
> CC ui/vnc-auth-sasl.o
> cc1: warnings being treated as errors
> /home/anthony/git/qemu/ui/vnc-auth-sasl.c: In function
> ‘vnc_sasl_client_cleanup’:
> /home/anthony/git/qemu/ui/vnc-auth-sasl.c:34:9: error: suggest
> parentheses around assignment used as truth value
> make: *** [ui/vnc-auth-sasl.o] Error 1
Looks like a GCC bug where
x = y = 0;
is converted to
x = (y = 0) != 0;
and the magic that does this inside the compiler causes the warning.
We should add a configure check to only add -Werror on compilers newer
than X (for example X could leave out GCC 4.5), so that this patch can
be reapplied.
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members
2012-03-08 16:08 ` Paolo Bonzini
@ 2012-03-08 16:25 ` Anthony Liguori
2012-03-08 18:07 ` Paolo Bonzini
0 siblings, 1 reply; 6+ messages in thread
From: Anthony Liguori @ 2012-03-08 16:25 UTC (permalink / raw)
To: Paolo Bonzini
Cc: QEMU Trivial, Stefan Hajnoczi, Anthony Liguori, qemu-devel,
Stefan Weil
On 03/08/2012 10:08 AM, Paolo Bonzini wrote:
> Il 08/03/2012 16:26, Stefan Hajnoczi ha scritto:
>> I had to drop this patch from the trivial patches tree, it tickles a
>> new gcc warning. Please resend with the necessary change.
>>
>> I cannot reproduce it on my build host here with gcc Debian 4.6.2-12
>> but Anthony reports the following Ubuntu/Linaro 4.5.2-8ubuntu4:
>>
>> CC ui/vnc-auth-sasl.o
>> cc1: warnings being treated as errors
>> /home/anthony/git/qemu/ui/vnc-auth-sasl.c: In function
>> ‘vnc_sasl_client_cleanup’:
>> /home/anthony/git/qemu/ui/vnc-auth-sasl.c:34:9: error: suggest
>> parentheses around assignment used as truth value
>> make: *** [ui/vnc-auth-sasl.o] Error 1
>
> Looks like a GCC bug where
>
> x = y = 0;
>
> is converted to
>
> x = (y = 0) != 0;
Curious, why convert like this? What does this optimization do?
Regards,
Anthony Liguori
>
> and the magic that does this inside the compiler causes the warning.
>
> We should add a configure check to only add -Werror on compilers newer
> than X (for example X could leave out GCC 4.5), so that this patch can
> be reapplied.
>
> Paolo
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members
2012-03-08 16:25 ` Anthony Liguori
@ 2012-03-08 18:07 ` Paolo Bonzini
0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2012-03-08 18:07 UTC (permalink / raw)
To: Anthony Liguori
Cc: QEMU Trivial, Stefan Hajnoczi, Anthony Liguori, qemu-devel,
Stefan Weil
Il 08/03/2012 17:25, Anthony Liguori ha scritto:
>>
>> Looks like a GCC bug where
>>
>> x = y = 0;
>>
>> is converted to
>>
>> x = (y = 0) != 0;
>
> Curious, why convert like this? What does this optimization do?
Nothing, it's just that if "y = 0" is an int (for some reason, I didn't
check if it's implicit promotion or just that y is already an int), then
it has to be converted back to a truth value before assigning to bool.
If you do
bool x;
int y;
x = y = 2;
x is actually set to 1.
Paolo
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-03-08 18:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-25 13:35 [Qemu-devel] [PATCH] vnc: Fix packed boolean struct members Stefan Weil
2012-03-05 13:15 ` Stefan Hajnoczi
2012-03-08 15:26 ` Stefan Hajnoczi
2012-03-08 16:08 ` Paolo Bonzini
2012-03-08 16:25 ` Anthony Liguori
2012-03-08 18:07 ` Paolo Bonzini
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).