aboutsummaryrefslogtreecommitdiff
path: root/debian/patches/0990_fix-DEBUG-and-TEST-builds.full.patch
blob: acb86e24de833fd28994254cedef4793a65d9dd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
Author: Mihai Moldovan <ionic@ionic.de>
Description: Several fixes for building debug versions of NX
Abstract:
 (1) In nx-X11/programs/Xserver/dix:
 .
 Fix several compile errors when specifying -DDEBUG globally. Previous GCC
 versions were more liberal and the code thus compiled.
 .
 Also initialize/reset a count variable correctly.
 .
 .
 (2) In nx-X11/programs/Xserver/hw/nxagent/Render.c:
 .
 Check for pSrc->pDrawable to exist instead of having nxagent segfault when
 it does not.
 .
 This enables the possibility of compiling all nxagent modules in TEST mode.

--- a/nx-X11/programs/Xserver/dix/dixfonts.c
+++ b/nx-X11/programs/Xserver/dix/dixfonts.c
@@ -2203,7 +2203,7 @@ dump_char_ascii(CharInfoPtr cip)
 	byte = 0;
 	for (l = 0; l <= (cip->metrics.rightSideBearing -
 			  cip->metrics.leftSideBearing); l++) {
-	    if (maskTab[l & 7] & row[l >> 3])
+	    if (maskTab[l & 7] & (((int*)row)[l >> 3]))
 		putchar('X');
 	    else
 		putchar('.');
--- a/nx-X11/programs/Xserver/hw/nxagent/Render.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c
@@ -946,7 +946,7 @@ void nxagentChangePicture(PicturePtr pPi
 
   #ifdef TEST
 
-  if (pPicture -> pDrawable -> type == DRAWABLE_PIXMAP)
+  if (pPicture && pPicture->pDrawable && pPicture -> pDrawable -> type == DRAWABLE_PIXMAP)
   {
     fprintf(stderr, "nxagentChangePicture: %sPixmap [%p] Picture [%p][%p].\n",
                 nxagentIsShmPixmap((PixmapPtr)pPicture -> pDrawable) ? "Shared " : "",
@@ -1008,7 +1008,7 @@ void nxagentComposite(CARD8 op, PictureP
 
   #ifdef DEBUG
 
-  if (pSrc -> pDrawable != NULL)
+  if (pSrc && pSrc -> pDrawable != NULL)
   {
     fprintf(stderr, "nxagentComposite: Source Picture [%lu][%p] with drawable [%s%s][%p].\n",
                 nxagentPicturePriv(pSrc) -> picture, (void *) pSrc,
@@ -1018,14 +1018,16 @@ void nxagentComposite(CARD8 op, PictureP
                              (void *) pSrc -> pDrawable);
   }
 
-  fprintf(stderr, "nxagentComposite: Destination Picture [%lu][%p] with drawable [%s%s][%p].\n",
-              nxagentPicturePriv(pDst) -> picture, (void *) pDst,
-              (pDst -> pDrawable -> type == DRAWABLE_PIXMAP &&
-                  nxagentIsShmPixmap((PixmapPtr) pDst -> pDrawable)) ? "Shared " : "",
-                       pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "Pixmap" : "Window",
-                           (void *) pDst -> pDrawable);
+  if (pDst && pDst->pDrawable) {
+    fprintf(stderr, "nxagentComposite: Destination Picture [%lu][%p] with drawable [%s%s][%p].\n",
+                nxagentPicturePriv(pDst) -> picture, (void *) pDst,
+                (pDst -> pDrawable -> type == DRAWABLE_PIXMAP &&
+                    nxagentIsShmPixmap((PixmapPtr) pDst -> pDrawable)) ? "Shared " : "",
+                         pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "Pixmap" : "Window",
+                             (void *) pDst -> pDrawable);
+  }
 
-  if (pMask)
+  if (pMask && pMask->pDrawable)
   {
     fprintf(stderr, "nxagentComposite: Mask Picture [%lu][%p] with drawable [%s%s][%p].\n",
                 nxagentPicturePriv(pMask) -> picture, (void *) pMask,
@@ -1042,12 +1044,13 @@ void nxagentComposite(CARD8 op, PictureP
     pDstRegion = nxagentCreateRegion(pDst -> pDrawable, NULL, xDst, yDst, width, height);
 
     #ifdef TEST
-    fprintf(stderr, "nxagentComposite: WARNING! Prevented operation on region [%d,%d,%d,%d] "
-                "for drawable at [%p] with type [%s].\n", pDstRegion -> extents.x1,
-                    pDstRegion -> extents.y1, pDstRegion -> extents.x2, pDstRegion -> extents.y2,
-                        (void *) pDst -> pDrawable,
-                            pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window");
-
+    if ((pDstRegion) && (pDst && pDst->pDrawable)) {
+      fprintf(stderr, "nxagentComposite: WARNING! Prevented operation on region [%d,%d,%d,%d] "
+                  "for drawable at [%p] with type [%s].\n", pDstRegion -> extents.x1,
+                      pDstRegion -> extents.y1, pDstRegion -> extents.x2, pDstRegion -> extents.y2,
+                          (void *) pDst -> pDrawable,
+                              pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window");
+    }
     #endif
 
     nxagentMarkCorruptedRegion(pDst -> pDrawable, pDstRegion);
@@ -1176,10 +1179,12 @@ void nxagentGlyphs(CARD8 op, PicturePtr 
   }
 
   #ifdef TEST
-  fprintf(stderr, "nxagentGlyphs: Called with source [%s][%p] destination [%s][%p] and size id [%d].\n",
-              (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"), (void *) pSrc, 
-                  (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"), (void *) pDst, 
-                      sizeID);
+  if ((pSrc && pSrc->pDrawable) && (pDst && pDst->pDrawable)) {
+      fprintf(stderr, "nxagentGlyphs: Called with source [%s][%p] destination [%s][%p] and size id [%d].\n",
+                  (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"), (void *) pSrc, 
+                      (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"), (void *) pDst, 
+                          sizeID);
+  }
   #endif
 
   pForm = NULL;
@@ -1264,9 +1269,11 @@ void nxagentGlyphs(CARD8 op, PicturePtr 
           nxagentDrawableStatus(pSrc -> pDrawable) == NotSynchronized)
   {
     #ifdef TEST
-    fprintf(stderr, "nxagentGlyphs: Synchronizing source [%s] at [%p].\n",
-                pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
-                    (void *) pSrc -> pDrawable);
+    if (pSrc && pSrc->pDrawable) {
+      fprintf(stderr, "nxagentGlyphs: Synchronizing source [%s] at [%p].\n",
+                  pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
+                      (void *) pSrc -> pDrawable);
+    }
     #endif
 
     /*
@@ -1280,12 +1287,14 @@ void nxagentGlyphs(CARD8 op, PicturePtr 
     if (pSrc -> repeat == 1 || nxagentGlyphsExtents == NullBox)
     {
       #ifdef DEBUG
-      fprintf(stderr, "nxagentGlyphs: Synchronizing source [%s] at [%p] "
-                  "with geometry [%d,%d,%d,%d].\n", 
-                      (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
-                          (void *) pSrc -> pDrawable, pSrc -> pDrawable -> x, pSrc -> pDrawable -> y,
-                              pSrc -> pDrawable -> x + pSrc -> pDrawable -> width,
-                                  pSrc -> pDrawable -> y + pSrc -> pDrawable -> height);
+      if (pSrc && pSrc->pDrawable) {
+        fprintf(stderr, "nxagentGlyphs: Synchronizing source [%s] at [%p] "
+                    "with geometry [%d,%d,%d,%d].\n", 
+                        (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
+                            (void *) pSrc -> pDrawable, pSrc -> pDrawable -> x, pSrc -> pDrawable -> y,
+                                pSrc -> pDrawable -> x + pSrc -> pDrawable -> width,
+                                    pSrc -> pDrawable -> y + pSrc -> pDrawable -> height);
+      }
       #endif
 
       nxagentSynchronizeBox(pSrc -> pDrawable, NullBox, NEVER_BREAK);
@@ -1293,12 +1302,14 @@ void nxagentGlyphs(CARD8 op, PicturePtr 
     else
     {
       #ifdef DEBUG
-      fprintf(stderr, "nxagentGlyphs: Synchronizing region [%d,%d,%d,%d] of source [%s] at [%p] "
-                  "with geometry [%d,%d,%d,%d].\n", glyphBox.x1, glyphBox.y1, glyphBox.x2, glyphBox.y2,
-                          (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
-                              (void *) pSrc -> pDrawable, pSrc -> pDrawable -> x, pSrc -> pDrawable -> y,
-                                  pSrc -> pDrawable -> x + pSrc -> pDrawable -> width,
-                                      pSrc -> pDrawable -> y + pSrc -> pDrawable -> height);
+      if (pSrc && pSrc->pDrawable) {
+        fprintf(stderr, "nxagentGlyphs: Synchronizing region [%d,%d,%d,%d] of source [%s] at [%p] "
+                    "with geometry [%d,%d,%d,%d].\n", glyphBox.x1, glyphBox.y1, glyphBox.x2, glyphBox.y2,
+                            (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
+                                (void *) pSrc -> pDrawable, pSrc -> pDrawable -> x, pSrc -> pDrawable -> y,
+                                    pSrc -> pDrawable -> x + pSrc -> pDrawable -> width,
+                                        pSrc -> pDrawable -> y + pSrc -> pDrawable -> height);
+      }
       #endif
 
       nxagentSynchronizeBox(pSrc -> pDrawable, &glyphBox, NEVER_BREAK);
@@ -1314,20 +1325,24 @@ void nxagentGlyphs(CARD8 op, PicturePtr 
           nxagentDrawableStatus(pDst -> pDrawable) == NotSynchronized)
   {
     #ifdef TEST
-    fprintf(stderr, "nxagentGlyphs: Synchronizing destination [%s] at [%p].\n",
-                pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
-                    (void *) pDst -> pDrawable);
+    if (pDst && pDst->pDrawable) {
+      fprintf(stderr, "nxagentGlyphs: Synchronizing destination [%s] at [%p].\n",
+                  pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
+                      (void *) pDst -> pDrawable);
+    }
     #endif
 
     if (nxagentGlyphsExtents == NullBox)
     {
       #ifdef DEBUG
-      fprintf(stderr, "nxagentGlyphs: Synchronizing destination [%s] at [%p] "
-                  "with geometry [%d,%d,%d,%d].\n", 
-                      (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
-                          (void *) pDst -> pDrawable, pDst -> pDrawable -> x, pDst -> pDrawable -> y,
-                              pDst -> pDrawable -> x + pDst -> pDrawable -> width,
-                                  pDst -> pDrawable -> y + pDst -> pDrawable -> height);
+      if (pDst && pDst->pDrawable) {
+        fprintf(stderr, "nxagentGlyphs: Synchronizing destination [%s] at [%p] "
+                    "with geometry [%d,%d,%d,%d].\n", 
+                        (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
+                            (void *) pDst -> pDrawable, pDst -> pDrawable -> x, pDst -> pDrawable -> y,
+                                pDst -> pDrawable -> x + pDst -> pDrawable -> width,
+                                    pDst -> pDrawable -> y + pDst -> pDrawable -> height);
+      }
       #endif
 
       nxagentSynchronizeBox(pDst -> pDrawable, NullBox, NEVER_BREAK);
@@ -1335,12 +1350,14 @@ void nxagentGlyphs(CARD8 op, PicturePtr 
     else
     {
       #ifdef DEBUG
-      fprintf(stderr, "nxagentGlyphs: Synchronizing region [%d,%d,%d,%d] of destination [%s] at [%p] "
-                  "with geometry [%d,%d,%d,%d].\n", glyphBox.x1, glyphBox.y1, glyphBox.x2, glyphBox.y2,
-                          (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
-                              (void *) pDst -> pDrawable, pDst -> pDrawable -> x, pDst -> pDrawable -> y,
-                                  pDst -> pDrawable -> x + pDst -> pDrawable -> width,
-                                      pDst -> pDrawable -> y + pDst -> pDrawable -> height);
+      if (pDst && pDst->pDrawable) {
+        fprintf(stderr, "nxagentGlyphs: Synchronizing region [%d,%d,%d,%d] of destination [%s] at [%p] "
+                    "with geometry [%d,%d,%d,%d].\n", glyphBox.x1, glyphBox.y1, glyphBox.x2, glyphBox.y2,
+                            (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
+                                (void *) pDst -> pDrawable, pDst -> pDrawable -> x, pDst -> pDrawable -> y,
+                                    pDst -> pDrawable -> x + pDst -> pDrawable -> width,
+                                        pDst -> pDrawable -> y + pDst -> pDrawable -> height);
+      }
       #endif
 
       nxagentSynchronizeBox(pDst -> pDrawable, &glyphBox, NEVER_BREAK);
@@ -1355,9 +1372,11 @@ void nxagentGlyphs(CARD8 op, PicturePtr 
   nxagentSetDrawableContainGlyphs(pDst -> pDrawable, 1);
 
   #ifdef TEST
-  fprintf(stderr, "nxagentGlyphs: Glyph flag set on drawable [%s][%p].\n",
-              pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
-                  (void *) pDst -> pDrawable);
+  if (pDst && pDst->pDrawable) {
+    fprintf(stderr, "nxagentGlyphs: Glyph flag set on drawable [%s][%p].\n",
+                pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
+                    (void *) pDst -> pDrawable);
+  }
   #endif
 
   #ifdef SPLIT_GLYPH_LISTS
@@ -1569,9 +1588,11 @@ void nxagentCompositeRects(CARD8 op, Pic
   }
 
   #ifdef TEST
-  fprintf(stderr, "nxagentCompositeRects: Called for picture at [%p] with [%s] at [%p].\n",
-              (void *) pDst, (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
-                  (void *) pDst -> pDrawable);
+  if (pDst && pDst->pDrawable) {
+    fprintf(stderr, "nxagentCompositeRects: Called for picture at [%p] with [%s] at [%p].\n",
+                (void *) pDst, (pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
+                    (void *) pDst -> pDrawable);
+  }
   #endif
 
   /*
@@ -1678,10 +1699,11 @@ FIXME: Is this useful or just a waste of
 
   #ifdef TEST
 
-  fprintf(stderr, "nxagentTrapezoids: Source is a [%s] of geometry [%d,%d].\n",
-              (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
-                  pSrc -> pDrawable -> width, pSrc -> pDrawable -> height);
-
+  if (pSrc && pSrc->pDrawable) {
+    fprintf(stderr, "nxagentTrapezoids: Source is a [%s] of geometry [%d,%d].\n",
+                (pSrc -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window"),
+                    pSrc -> pDrawable -> width, pSrc -> pDrawable -> height);
+  }
   if (pSrc ->pDrawable != pDst -> pDrawable)
   {
     fprintf(stderr, "nxagentTrapezoids: Destination is a [%s] of geometry [%d,%d].\n",
@@ -1702,11 +1724,13 @@ FIXME: Is this useful or just a waste of
                              nxagentTrapezoidExtents) == rgnIN)
   {
     #ifdef TEST
-    fprintf(stderr, "nxagentTrapezoids: WARNING! Prevented operation on region [%d,%d,%d,%d] already dirty "
-                "for drawable [%s][%p].\n", nxagentTrapezoidExtents -> x1, nxagentTrapezoidExtents -> y1,
-                    nxagentTrapezoidExtents -> x2, nxagentTrapezoidExtents -> y2,
-                        pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
-                            (void *) pDst -> pDrawable);
+    if (pDst && pDst->pDrawable) {
+      fprintf(stderr, "nxagentTrapezoids: WARNING! Prevented operation on region [%d,%d,%d,%d] already dirty "
+                  "for drawable [%s][%p].\n", nxagentTrapezoidExtents -> x1, nxagentTrapezoidExtents -> y1,
+                      nxagentTrapezoidExtents -> x2, nxagentTrapezoidExtents -> y2,
+                          pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
+                              (void *) pDst -> pDrawable);
+    }
     #endif
 
     if (pDst -> pDrawable -> type == DRAWABLE_PIXMAP)
@@ -1732,11 +1756,13 @@ FIXME: Is this useful or just a waste of
                                      nxagentTrapezoidExtents -> y2 - nxagentTrapezoidExtents -> y1);
 
     #ifdef TEST
-    fprintf(stderr, "nxagentTrapezoids: WARNING! Prevented operation on region [%d,%d,%d,%d] "
-                "for drawable [%s][%p].\n", pDstRegion -> extents.x1, pDstRegion -> extents.y1,
-                    pDstRegion -> extents.x2, pDstRegion -> extents.y2,
-                        pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
-                            (void *) pDst -> pDrawable);
+    if (pDst && pDst->pDrawable) {
+      fprintf(stderr, "nxagentTrapezoids: WARNING! Prevented operation on region [%d,%d,%d,%d] "
+                  "for drawable [%s][%p].\n", pDstRegion -> extents.x1, pDstRegion -> extents.y1,
+                      pDstRegion -> extents.x2, pDstRegion -> extents.y2,
+                          pDst -> pDrawable -> type == DRAWABLE_PIXMAP ? "pixmap" : "window",
+                              (void *) pDst -> pDrawable);
+    }
     #endif
 
     nxagentMarkCorruptedRegion(pDst -> pDrawable, pDstRegion);
--- a/nx-X11/programs/Xserver/hw/nxagent/X/NXdispatch.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/X/NXdispatch.c
@@ -735,7 +735,7 @@ Reply   Total	Cached	Bits In			Bits Out	
 
 		client->sequence++;
 #ifdef DEBUG
-		if (client->requestLogIndex == MAX_REQUEST_LOG)
+		if ((client->requestLogIndex >= MAX_REQUEST_LOG) || (client->requestLogIndex <= 0))
 		    client->requestLogIndex = 0;
 		client->requestLog[client->requestLogIndex] = MAJOROP;
 		client->requestLogIndex++;
--- a/nx-X11/programs/Xserver/hw/nxagent/X/NXdixfonts.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/X/NXdixfonts.c
@@ -2351,7 +2351,7 @@ dump_char_ascii(CharInfoPtr cip)
 	byte = 0;
 	for (l = 0; l <= (cip->metrics.rightSideBearing -
 			  cip->metrics.leftSideBearing); l++) {
-	    if (maskTab[l & 7] & row[l >> 3])
+	    if (maskTab[l & 7] & (((int *)row)[l >> 3]))
 		putchar('X');
 	    else
 		putchar('.');