qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] vnc: Fix packed boolean struct members
@ 2012-03-08 21:58 Stefan Weil
  2012-03-15  8:28 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Weil @ 2012-03-08 21:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Anthony Liguori

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.

v2:

Some versions of gcc complain after this modification,
for example gcc (Debian 4.4.5-8) 4.4.5):

ui/vnc-auth-sasl.c: In function ‘vnc_sasl_client_cleanup’:
ui/vnc-auth-sasl.c:34: error: suggest parentheses around assignment used as truth value

Obviously, the compiler does not like code which does
bool = unsigned = bool = 0

Splitting that code in three statements works.

Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 ui/vnc-auth-sasl.c |    4 +++-
 ui/vnc-auth-sasl.h |    4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
index e2045fc..8fba770 100644
--- a/ui/vnc-auth-sasl.c
+++ b/ui/vnc-auth-sasl.c
@@ -31,7 +31,9 @@
 void vnc_sasl_client_cleanup(VncState *vs)
 {
     if (vs->sasl.conn) {
-        vs->sasl.runSSF = vs->sasl.waitWriteSSF = vs->sasl.wantSSF = 0;
+        vs->sasl.runSSF = false;
+        vs->sasl.wantSSF = false;
+        vs->sasl.waitWriteSSF = 0;
         vs->sasl.encodedLength = vs->sasl.encodedOffset = 0;
         vs->sasl.encoded = NULL;
         g_free(vs->sasl.username);
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] 2+ messages in thread

* Re: [Qemu-devel] [PATCH v2] vnc: Fix packed boolean struct members
  2012-03-08 21:58 [Qemu-devel] [PATCH v2] vnc: Fix packed boolean struct members Stefan Weil
@ 2012-03-15  8:28 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2012-03-15  8:28 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, Anthony Liguori, qemu-devel

On Thu, Mar 08, 2012 at 10:58:06PM +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.
> 
> v2:
> 
> Some versions of gcc complain after this modification,
> for example gcc (Debian 4.4.5-8) 4.4.5):
> 
> ui/vnc-auth-sasl.c: In function ‘vnc_sasl_client_cleanup’:
> ui/vnc-auth-sasl.c:34: error: suggest parentheses around assignment used as truth value
> 
> Obviously, the compiler does not like code which does
> bool = unsigned = bool = 0
> 
> Splitting that code in three statements works.
> 
> Cc: Anthony Liguori <aliguori@us.ibm.com>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  ui/vnc-auth-sasl.c |    4 +++-
>  ui/vnc-auth-sasl.h |    4 ++--
>  2 files changed, 5 insertions(+), 3 deletions(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-15  9:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-08 21:58 [Qemu-devel] [PATCH v2] vnc: Fix packed boolean struct members Stefan Weil
2012-03-15  8:28 ` Stefan Hajnoczi

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).