70 lines
2.3 KiB
Diff
70 lines
2.3 KiB
Diff
From 8b328d4ee3873bc0a7a34f2cb9d301827244b98c Mon Sep 17 00:00:00 2001
|
|
From: Aaron Plattner <aplattner@nvidia.com>
|
|
Date: Fri, 21 Dec 2012 07:37:33 -0800
|
|
Subject: [PATCH 1/2] dix: Make small bitfields that store enums unsigned
|
|
|
|
Commit 31bf81772e146af79b0c456aae2159eba8b0280f changed the clientState field
|
|
from a signed int to a signed int 2-bit bitfield. The ClientState enum that is
|
|
expected to be assigned to this field has four values: ClientStateInitial (0),
|
|
ClientStateRunning (1), ClientStateRetained (2), and ClientStateGone (3).
|
|
However, because this bitfield is signed, ClientStateRetained becomes -2 when
|
|
assigned, and ClientStateGone becomes -1. This causes warnings:
|
|
|
|
test.c:54:10: error: case label value exceeds maximum value for type [-Werror]
|
|
test.c:55:10: error: case label value exceeds maximum value for type [-Werror]
|
|
|
|
The code here is a switch statement:
|
|
|
|
53 switch (client->clientState) {
|
|
54 case ClientStateGone:
|
|
55 case ClientStateRetained:
|
|
56 [...]
|
|
57 break;
|
|
58
|
|
59 default:
|
|
60 [...]
|
|
61 break;
|
|
62 }
|
|
|
|
It also causes bizarre problems like this:
|
|
|
|
client->clientState = ClientStateGone;
|
|
assert(client->clientState == ClientStateGone); // this assert fails
|
|
|
|
Also change the signedness of nearby bitfields to match.
|
|
|
|
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
|
|
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
|
|
Reviewed-by: Colin Harrison <colin.harrison at virgin.net>
|
|
Signed-off-by: Keith Packard <keithp@keithp.com>
|
|
---
|
|
include/dixstruct.h | 12 ++++++------
|
|
1 file changed, 6 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/include/dixstruct.h b/include/dixstruct.h
|
|
index c1236f5..6784819 100644
|
|
--- a/include/dixstruct.h
|
|
+++ b/include/dixstruct.h
|
|
@@ -90,12 +90,12 @@ typedef struct _Client {
|
|
Mask clientAsMask;
|
|
short index;
|
|
unsigned char majorOp, minorOp;
|
|
- int swapped:1;
|
|
- int local:1;
|
|
- int big_requests:1; /* supports large requests */
|
|
- int clientGone:1;
|
|
- int closeDownMode:2;
|
|
- int clientState:2;
|
|
+ unsigned int swapped:1;
|
|
+ unsigned int local:1;
|
|
+ unsigned int big_requests:1; /* supports large requests */
|
|
+ unsigned int clientGone:1;
|
|
+ unsigned int closeDownMode:2;
|
|
+ unsigned int clientState:2;
|
|
char smart_priority;
|
|
short noClientException; /* this client died or needs to be killed */
|
|
int priority;
|
|
--
|
|
1.8.0.2
|
|
|