vnc: Fix packed boolean struct members
PATCH v2 1/1 vnc: Fix packed boolean struct members
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.
--- ui/vnc-auth-sasl.c | 4 +++- ui/vnc-auth-sasl.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-)
ui/vnc-auth-sasl.c +3 -1
@@ -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);
ui/vnc-auth-sasl.h +2 -2
@@ -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
Signature · 1 line
1.7.9
Stefan Hajnoczi
AppliedQuoted 20 lines · Stefan Weil
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 valueObviously, the compiler does not like code which does bool = unsigned = bool = 0
Quoted 8 lines
Splitting that code in three statements works.
Cc Anthony Liguori <[email protected]>Signed-off-by Stefan Weil <[email protected]>--- 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