Commit 50b25a1210a9a2926a2c22017f63a68483de0299

Ran Benita 2012-07-17T11:03:43

Use xkb_group_index_t for group variables throughout Signed-off-by: Ran Benita <ran234@gmail.com>

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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 071996a..46f2139 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -739,7 +739,7 @@ write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
 
 static bool
 write_keysyms(struct xkb_keymap *keymap, char **buf, size_t *size,
-              size_t *offset, struct xkb_key *key, unsigned int group)
+              size_t *offset, struct xkb_key *key, xkb_group_index_t group)
 {
     const xkb_keysym_t *syms;
     int num_syms, level;
@@ -780,7 +780,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
               size_t *offset)
 {
     struct xkb_key *key;
-    int group, tmp;
+    xkb_group_index_t group, tmp;
     bool showActions;
 
     if (keymap->symbols_section_name)
@@ -828,7 +828,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
                         continue;
                     type = XkbKeyTypeIndex(key, group);
                     write_buf(keymap, buf, size, offset,
-                              "\n\t\t\ttype[group%d]= \"%s\",",
+                              "\n\t\t\ttype[group%u]= \"%s\",",
                               group + 1,
                               darray_item(keymap->types, type).name);
                 }
@@ -862,7 +862,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
 
         case XkbRedirectIntoRange:
             write_buf(keymap, buf, size, offset,
-                      "\n\t\t\tgroupsRedirect= Group%d,",
+                      "\n\t\t\tgroupsRedirect= Group%u,",
                       key->out_of_range_group_number + 1);
             break;
         }
@@ -890,13 +890,13 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
                 if (group != 0)
                     write_buf(keymap, buf, size, offset, ",");
                 write_buf(keymap, buf, size, offset,
-                          "\n\t\t\tsymbols[Group%d]= [ ", group + 1);
+                          "\n\t\t\tsymbols[Group%u]= [ ", group + 1);
                 if (!write_keysyms(keymap, buf, size, offset, key, group))
                     return false;
                 write_buf(keymap, buf, size, offset, " ]");
                 if (showActions) {
                     write_buf(keymap, buf, size, offset,
-                              ",\n\t\t\tactions[Group%d]= [ ", group + 1);
+                              ",\n\t\t\tactions[Group%u]= [ ", group + 1);
                     for (level = 0;
                          level < XkbKeyGroupWidth(keymap, key, group);
                          level++) {
diff --git a/src/map.c b/src/map.c
index d35d8bc..b9c9874 100644
--- a/src/map.c
+++ b/src/map.c
@@ -244,7 +244,7 @@ xkb_map_led_get_index(struct xkb_keymap *keymap, const char *name)
  */
 unsigned int
 xkb_key_get_level(struct xkb_state *state, xkb_keycode_t kc,
-                  unsigned int group)
+                  xkb_group_index_t group)
 {
     struct xkb_keymap *keymap = xkb_state_get_map(state);
     struct xkb_key_type *type;
@@ -270,11 +270,12 @@ xkb_key_get_level(struct xkb_state *state, xkb_keycode_t kc,
  * Returns the group to use for the given key and state, taking
  * wrapping/clamping/etc into account.
  */
-unsigned int
+xkb_group_index_t
 xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc)
 {
     struct xkb_keymap *keymap = xkb_state_get_map(state);
-    unsigned int ret = xkb_state_serialize_group(state, XKB_STATE_EFFECTIVE);
+    xkb_group_index_t ret = xkb_state_serialize_group(state,
+                                                      XKB_STATE_EFFECTIVE);
     struct xkb_key *key;
 
     if (!XkbKeycodeInRange(keymap, kc))
@@ -309,7 +310,7 @@ xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc)
  */
 int
 xkb_key_get_syms_by_level(struct xkb_keymap *keymap, struct xkb_key *key,
-                          unsigned int group, unsigned int level,
+                          xkb_group_index_t group, unsigned int level,
                           const xkb_keysym_t **syms_out)
 {
     int num_syms;
@@ -341,7 +342,8 @@ xkb_key_get_syms(struct xkb_state *state, xkb_keycode_t kc,
 {
     struct xkb_keymap *keymap = xkb_state_get_map(state);
     struct xkb_key *key;
-    int group, level;
+    xkb_group_index_t group;
+    unsigned int level;
 
     if (!state || !XkbKeycodeInRange(keymap, kc))
         return -1;
diff --git a/src/state.c b/src/state.c
index 94bff55..6b0dae3 100644
--- a/src/state.c
+++ b/src/state.c
@@ -109,7 +109,8 @@ struct xkb_state {
 static union xkb_action *
 xkb_key_get_action(struct xkb_state *state, xkb_keycode_t kc)
 {
-    unsigned int group, level;
+    xkb_group_index_t group;
+    unsigned int level;
     struct xkb_key *key = NULL;
 
     if (XkbKeycodeInRange(state->keymap, kc))
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 76ab3aa..55a89f2 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -136,7 +136,7 @@ struct xkb_mod_action {
 struct xkb_group_action {
     uint8_t type;
     uint8_t flags;
-    int16_t group;
+    int32_t group;
 };
 
 struct xkb_iso_action {
@@ -144,7 +144,7 @@ struct xkb_iso_action {
     uint8_t flags;
     uint8_t mask;
     uint8_t real_mods;
-    uint8_t group;
+    int32_t group;
     uint8_t affect;
     uint16_t vmods;
 };
@@ -270,7 +270,7 @@ struct xkb_behavior {
 struct xkb_indicator_map {
     unsigned char flags;
     unsigned char which_groups;
-    unsigned char groups;
+    uint32_t groups;
     unsigned char which_mods;
     struct xkb_mods mods;
     unsigned int ctrls;
@@ -314,12 +314,12 @@ struct xkb_key {
 
     unsigned char kt_index[XkbNumKbdGroups];
 
-    unsigned int num_groups;
+    xkb_group_index_t num_groups;
     /* How many levels the largest group has. */
     unsigned char width;
 
     uint8_t out_of_range_group_action;
-    uint8_t out_of_range_group_number;
+    xkb_group_index_t out_of_range_group_number;
 
     /* per level/group index into 'syms' */
     int *sym_index;
@@ -387,26 +387,27 @@ XkbKeyGetKeycode(struct xkb_keymap *keymap, struct xkb_key *key)
     xkb_foreach_key_from(iter, keymap, keymap->min_key_code)
 
 static inline unsigned char
-XkbKeyTypeIndex(struct xkb_key *key, unsigned int group)
+XkbKeyTypeIndex(struct xkb_key *key, xkb_group_index_t group)
 {
     return key->kt_index[group & 0x3];
 }
 
 static inline struct xkb_key_type *
-XkbKeyType(struct xkb_keymap *keymap, struct xkb_key *key, unsigned int group)
+XkbKeyType(struct xkb_keymap *keymap, struct xkb_key *key,
+           xkb_group_index_t group)
 {
     return &darray_item(keymap->types, XkbKeyTypeIndex(key, group));
 }
 
 static inline uint16_t
 XkbKeyGroupWidth(struct xkb_keymap *keymap, struct xkb_key *key,
-                 unsigned int group)
+                 xkb_group_index_t group)
 {
     return XkbKeyType(keymap, key, group)->num_levels;
 }
 
 static inline unsigned int
-XkbKeyNumSyms(struct xkb_key *key, unsigned int group, unsigned int level)
+XkbKeyNumSyms(struct xkb_key *key, xkb_group_index_t group, unsigned int level)
 {
     return key->num_syms[group * key->width + level];
 }
@@ -418,13 +419,14 @@ XkbKeySym(struct xkb_key *key, int ndx)
 }
 
 static inline int
-XkbKeySymOffset(struct xkb_key *key, unsigned group, unsigned int level)
+XkbKeySymOffset(struct xkb_key *key, xkb_group_index_t group,
+                unsigned int level)
 {
     return key->sym_index[group * key->width + level];
 }
 
 static inline xkb_keysym_t *
-XkbKeySymEntry(struct xkb_key *key, unsigned group, unsigned int level)
+XkbKeySymEntry(struct xkb_key *key, xkb_group_index_t group, unsigned int level)
 {
     return XkbKeySym(key, XkbKeySymOffset(key, group, level));
 }
@@ -435,7 +437,7 @@ XkbKeyHasActions(struct xkb_key *key)
     return key->acts_index != 0;
 }
 
-static inline unsigned char
+static inline unsigned int
 XkbKeyNumActions(struct xkb_key *key)
 {
     if (XkbKeyHasActions(key))
@@ -451,7 +453,7 @@ XkbKeyActionsPtr(struct xkb_keymap *keymap, struct xkb_key *key)
 
 static inline union xkb_action *
 XkbKeyActionEntry(struct xkb_keymap *keymap, struct xkb_key *key,
-                  unsigned int group, unsigned int level)
+                  xkb_group_index_t group, unsigned int level)
 {
     if (XkbKeyHasActions(key))
         return &XkbKeyActionsPtr(keymap, key)[key->width * group + level];
@@ -482,11 +484,11 @@ xkb_key_get_group(struct xkb_state *state, xkb_keycode_t kc);
 
 extern unsigned int
 xkb_key_get_level(struct xkb_state *state, xkb_keycode_t kc,
-                  unsigned int group);
+                  xkb_group_index_t group);
 
 extern int
 xkb_key_get_syms_by_level(struct xkb_keymap *keymap, struct xkb_key *key,
-                          unsigned int group, unsigned int level,
+                          xkb_group_index_t group, unsigned int level,
                           const xkb_keysym_t **syms_out);
 
 /**
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 07e881e..c10d543 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -320,7 +320,8 @@ HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
 
 static bool
 CheckGroupField(struct xkb_keymap *keymap, unsigned action,
-                ExprDef * value, unsigned *flags_inout, int *grp_rtrn)
+                ExprDef * value, unsigned *flags_inout,
+                xkb_group_index_t *grp_rtrn)
 {
     ExprDef *spec;
     ExprResult rtrn;
@@ -352,7 +353,7 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
     struct xkb_group_action *act;
     unsigned rtrn;
     unsigned t1;
-    int t2;
+    xkb_group_index_t t2;
 
     act = (struct xkb_group_action *) action;
     if (array_ndx != NULL) {
@@ -391,7 +392,7 @@ HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
 {
     struct xkb_group_action *act;
     unsigned t1;
-    int t2;
+    xkb_group_index_t t2;
 
     act = (struct xkb_group_action *) action;
     if ((array_ndx != NULL) && (field == F_Group))
@@ -584,7 +585,7 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
     ExprResult rtrn;
     struct xkb_iso_action *act;
     unsigned flags, mods;
-    int group;
+    xkb_group_index_t group;
 
     act = (struct xkb_iso_action *) action;
     switch (field) {
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index a0e1220..994a5f6 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -53,7 +53,7 @@ typedef struct _LEDInfo {
     unsigned char real_mods;
     unsigned short vmods;
     unsigned char which_groups;
-    unsigned char groups;
+    uint32_t groups;
     unsigned int ctrls;
 } LEDInfo;
 
@@ -308,25 +308,24 @@ AddInterp(CompatInfo * info, SymInterpInfo * new)
 }
 
 static bool
-AddGroupCompat(CompatInfo * info, unsigned group, GroupCompatInfo * newGC)
+AddGroupCompat(CompatInfo *info, xkb_group_index_t group, GroupCompatInfo *new)
 {
     GroupCompatInfo *gc;
-    enum merge_mode merge;
 
-    merge = newGC->merge;
     gc = &info->groupCompat[group];
-    if (((gc->real_mods == newGC->real_mods) &&
-         (gc->vmods == newGC->vmods))) {
+    if (gc->real_mods == new->real_mods && gc->vmods == new->vmods)
         return true;
-    }
-    if (((gc->file_id == newGC->file_id) && (warningLevel > 0))
-        || (warningLevel > 9)) {
-        WARN("Compat map for group %d redefined\n", group + 1);
+
+    if ((gc->file_id == new->file_id && warningLevel > 0) ||
+        warningLevel > 9) {
+        WARN("Compat map for group %u redefined\n", group + 1);
         ACTION("Using %s definition\n",
-               (merge == MERGE_AUGMENT ? "old" : "new"));
+               (new->merge == MERGE_AUGMENT ? "old" : "new"));
     }
-    if (newGC->defined && (merge != MERGE_AUGMENT || !gc->defined))
-        *gc = *newGC;
+
+    if (new->defined && (new->merge != MERGE_AUGMENT || !gc->defined))
+        *gc = *new;
+
     return true;
 }
 
@@ -492,7 +491,7 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from,
     SymInterpInfo *si;
     LEDInfo *led, *rtrn, *next;
     GroupCompatInfo *gcm;
-    int i;
+    xkb_group_index_t i;
 
     if (from->errorCount > 0) {
         into->errorCount += from->errorCount;
@@ -943,18 +942,17 @@ HandleGroupCompatDef(GroupCompatDef *def, struct xkb_keymap *keymap,
 
     if (def->merge != MERGE_DEFAULT)
         merge = def->merge;
-    if (!XkbIsLegalGroup(def->group - 1)) {
-        ERROR("Keyboard group must be in the range 1..%d\n",
-              XkbNumKbdGroups + 1);
-        ACTION("Compatibility map for illegal group %d ignored\n",
-               def->group);
+    if (def->group < 1 || def->group > XkbNumKbdGroups) {
+        ERROR("Keyboard group must be in the range 1..%u\n",
+               XkbNumKbdGroups);
+        ACTION("Compatibility map for illegal group %u ignored\n", def->group);
         return false;
     }
     tmp.file_id = info->file_id;
     tmp.merge = merge;
     if (!ExprResolveVModMask(def->def, &val, keymap)) {
         ERROR("Expected a modifier mask in group compatibility definition\n");
-        ACTION("Ignoring illegal compatibility map for group %d\n",
+        ACTION("Ignoring illegal compatibility map for group %u\n",
                def->group);
         return false;
     }
@@ -1228,7 +1226,7 @@ bool
 CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
                  enum merge_mode merge)
 {
-    int i;
+    xkb_group_index_t i;
     CompatInfo info;
     GroupCompatInfo *gcm;
 
@@ -1332,7 +1330,7 @@ UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
  */
 static struct xkb_sym_interpret *
 FindInterpForKey(struct xkb_keymap *keymap, struct xkb_key *key,
-                 uint32_t group, uint32_t level)
+                 xkb_group_index_t group, uint32_t level)
 {
     struct xkb_sym_interpret *ret = NULL;
     struct xkb_sym_interpret *interp;
@@ -1396,7 +1394,8 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key)
     union xkb_action *acts;
     uint32_t vmodmask = 0;
     int num_acts = 0;
-    int group, level;
+    xkb_group_index_t group;
+    int level;
     int i;
 
     /* If we've been told not to bind interps to this key, then don't. */
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 2dcc74c..d22ffc2 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -620,7 +620,7 @@ ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr,
         return ret;
 
     if (val_rtrn->uval == 0 || val_rtrn->uval > XkbNumKbdGroups) {
-        ERROR("Group index %d is out of range (1..%d)\n",
+        ERROR("Group index %u is out of range (1..%d)\n",
               val_rtrn->uval, XkbNumKbdGroups);
         return false;
     }
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index ea03e9c..532ea4c 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -94,7 +94,7 @@ typedef struct _KeyInfo {
     xkb_atom_t dfltType;
 
     uint8_t out_of_range_group_action;
-    uint8_t out_of_range_group_number;
+    xkb_group_index_t out_of_range_group_number;
 } KeyInfo;
 
 /**
@@ -103,7 +103,7 @@ typedef struct _KeyInfo {
 static void
 InitKeyInfo(KeyInfo *keyi, unsigned file_id)
 {
-    int i;
+    xkb_group_index_t i;
     static const char dflt[4] = "*";
 
     keyi->defined = 0;
@@ -133,7 +133,7 @@ InitKeyInfo(KeyInfo *keyi, unsigned file_id)
 static void
 FreeKeyInfo(KeyInfo *keyi)
 {
-    int i;
+    xkb_group_index_t i;
 
     for (i = 0; i < XkbNumKbdGroups; i++) {
         darray_free(keyi->syms[i]);
@@ -151,7 +151,7 @@ FreeKeyInfo(KeyInfo *keyi)
 static bool
 CopyKeyInfo(KeyInfo * old, KeyInfo * new, bool clearOld)
 {
-    int i;
+    xkb_group_index_t i;
 
     *new = *old;
 
@@ -194,7 +194,7 @@ typedef struct _SymbolsInfo {
     int errorCount;
     unsigned file_id;
     enum merge_mode merge;
-    unsigned explicit_group;
+    xkb_group_index_t explicit_group;
     darray(KeyInfo) keys;
     KeyInfo dflt;
     VModInfo vmods;
@@ -208,7 +208,7 @@ static void
 InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap *keymap,
                 unsigned file_id)
 {
-    int i;
+    xkb_group_index_t i;
 
     info->name = NULL;
     info->explicit_group = 0;
@@ -242,7 +242,7 @@ FreeSymbolsInfo(SymbolsInfo * info)
 }
 
 static bool
-ResizeKeyGroup(KeyInfo *keyi, unsigned int group, unsigned int numLevels,
+ResizeKeyGroup(KeyInfo *keyi, xkb_group_index_t group, unsigned int numLevels,
                unsigned sizeSyms, bool forceActions)
 {
     int i;
@@ -280,7 +280,7 @@ enum key_group_selector {
 
 static bool
 MergeKeyGroups(SymbolsInfo * info,
-               KeyInfo * into, KeyInfo * from, unsigned group)
+               KeyInfo * into, KeyInfo * from, xkb_group_index_t group)
 {
     darray_xkb_keysym_t resultSyms;
     enum key_group_selector using = NONE;
@@ -346,7 +346,7 @@ MergeKeyGroups(SymbolsInfo * info,
                 }
                 if (report) {
                     WARN
-                        ("Multiple actions for level %d/group %d on key %s\n",
+                        ("Multiple actions for level %d/group %u on key %s\n",
                         i + 1, group + 1, longText(into->name));
                     ACTION("Using %s, ignoring %s\n",
                            XkbcActionTypeText(use->type),
@@ -429,7 +429,7 @@ MergeKeyGroups(SymbolsInfo * info,
             use = TO;
 
         if (toSize && fromSize && report) {
-            INFO("Multiple symbols for group %d, level %d on key %s\n",
+            INFO("Multiple symbols for group %u, level %d on key %s\n",
                  group + 1, i + 1, longText(into->name));
             ACTION("Using %s, ignoring %s\n",
                    (use == FROM ? "from" : "to"),
@@ -486,7 +486,7 @@ static bool
 MergeKeys(SymbolsInfo *info, struct xkb_keymap *keymap,
           KeyInfo *into, KeyInfo *from)
 {
-    int i;
+    xkb_group_index_t i;
     unsigned collide = 0;
     bool report;
 
@@ -813,7 +813,7 @@ HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
 
 static bool
 GetGroupIndex(KeyInfo *keyi, struct xkb_keymap *keymap,
-              ExprDef * arrayNdx, unsigned what, unsigned *ndx_rtrn)
+              ExprDef *arrayNdx, unsigned what, xkb_group_index_t *ndx_rtrn)
 {
     const char *name;
     ExprResult tmp;
@@ -824,7 +824,7 @@ GetGroupIndex(KeyInfo *keyi, struct xkb_keymap *keymap,
         name = "actions";
 
     if (arrayNdx == NULL) {
-        int i;
+        xkb_group_index_t i;
         unsigned defined;
         if (what == SYMBOLS)
             defined = keyi->symsDefined;
@@ -837,7 +837,7 @@ GetGroupIndex(KeyInfo *keyi, struct xkb_keymap *keymap,
                 return true;
             }
         }
-        ERROR("Too many groups of %s for key %s (max %d)\n", name,
+        ERROR("Too many groups of %s for key %s (max %u)\n", name,
               longText(keyi->name), XkbNumKbdGroups + 1);
         ACTION("Ignoring %s defined for extra groups\n", name);
         return false;
@@ -856,9 +856,9 @@ static bool
 AddSymbolsToKey(KeyInfo *keyi, struct xkb_keymap *keymap,
                 ExprDef *arrayNdx, ExprDef *value, SymbolsInfo *info)
 {
-    unsigned ndx, nSyms, nLevels;
-    unsigned int i;
-    long j;
+    xkb_group_index_t ndx;
+    size_t nSyms, nLevels;
+    size_t i, j;
 
     if (!GetGroupIndex(keyi, keymap, arrayNdx, SYMBOLS, &ndx))
         return false;
@@ -868,13 +868,13 @@ AddSymbolsToKey(KeyInfo *keyi, struct xkb_keymap *keymap,
     }
     if (value->op != ExprKeysymList) {
         ERROR("Expected a list of symbols, found %s\n", exprOpText(value->op));
-        ACTION("Ignoring symbols for group %d of %s\n", ndx + 1,
+        ACTION("Ignoring symbols for group %u of %s\n", ndx + 1,
                longText(keyi->name));
         return false;
     }
     if (!darray_empty(keyi->syms[ndx])) {
-        ERROR("Symbols for key %s, group %d already defined\n",
-               longText(keyi->name), ndx + 1);
+        ERROR("Symbols for key %s, group %u already defined\n",
+              longText(keyi->name), ndx + 1);
         ACTION("Ignoring duplicate definition\n");
         return false;
     }
@@ -882,7 +882,7 @@ AddSymbolsToKey(KeyInfo *keyi, struct xkb_keymap *keymap,
     nLevels = darray_size(value->value.list.symsMapIndex);
     if ((keyi->numLevels[ndx] < nSyms || darray_empty(keyi->syms[ndx])) &&
         (!ResizeKeyGroup(keyi, ndx, nLevels, nSyms, false))) {
-        WSGO("Could not resize group %d of key %s to contain %d levels\n",
+        WSGO("Could not resize group %u of key %s to contain %zu levels\n",
              ndx + 1, longText(keyi->name), nSyms);
         ACTION("Symbols lost\n");
         return false;
@@ -905,7 +905,7 @@ AddSymbolsToKey(KeyInfo *keyi, struct xkb_keymap *keymap,
                                            darray_item(keyi->symsMapIndex[ndx],
                                                        i) + j))) {
                 WARN(
-                    "Could not resolve keysym %s for key %s, group %d (%s), level %d\n",
+                    "Could not resolve keysym %s for key %s, group %u (%s), level %zu\n",
                     darray_item(value->value.list.syms, i),
                     longText(keyi->name),
                     ndx + 1,
@@ -937,8 +937,9 @@ static bool
 AddActionsToKey(KeyInfo *keyi, struct xkb_keymap *keymap, ExprDef *arrayNdx,
                 ExprDef *value, SymbolsInfo *info)
 {
-    unsigned int i;
-    unsigned ndx, nActs;
+    size_t i;
+    xkb_group_index_t ndx;
+    size_t nActs;
     ExprDef *act;
     struct xkb_any_action *toAct;
 
@@ -951,13 +952,13 @@ AddActionsToKey(KeyInfo *keyi, struct xkb_keymap *keymap, ExprDef *arrayNdx,
     }
     if (value->op != ExprActionList) {
         WSGO("Bad expression type (%d) for action list value\n", value->op);
-        ACTION("Ignoring actions for group %d of %s\n", ndx,
+        ACTION("Ignoring actions for group %u of %s\n", ndx,
                longText(keyi->name));
         return false;
     }
     if (!darray_empty(keyi->acts[ndx])) {
-        WSGO("Actions for key %s, group %d already defined\n",
-             longText(keyi->name), ndx);
+        WSGO("Actions for key %s, group %u already defined\n",
+              longText(keyi->name), ndx);
         return false;
     }
     for (nActs = 0, act = value->value.child; act != NULL; nActs++) {
@@ -969,7 +970,7 @@ AddActionsToKey(KeyInfo *keyi, struct xkb_keymap *keymap, ExprDef *arrayNdx,
     }
     if ((keyi->numLevels[ndx] < nActs || darray_empty(keyi->acts[ndx])) &&
         !ResizeKeyGroup(keyi, ndx, nActs, nActs, true)) {
-        WSGO("Could not resize group %d of key %s\n", ndx,
+        WSGO("Could not resize group %u of key %s\n", ndx,
               longText(keyi->name));
         ACTION("Actions lost\n");
         return false;
@@ -982,7 +983,7 @@ AddActionsToKey(KeyInfo *keyi, struct xkb_keymap *keymap, ExprDef *arrayNdx,
         if (!HandleActionDef(act, keymap, toAct, info->action)) {
             ERROR("Illegal action definition for %s\n",
                   longText(keyi->name));
-            ACTION("Action for group %d/level %d ignored\n", ndx + 1, i + 1);
+            ACTION("Action for group %u/level %zu ignored\n", ndx + 1, i + 1);
         }
         act = (ExprDef *) act->common.next;
     }
@@ -1267,13 +1268,13 @@ HandleSymbolsBody(VarDef *def, struct xkb_keymap *keymap, KeyInfo *keyi,
 static bool
 SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
 {
-    unsigned group = info->explicit_group;
+    xkb_group_index_t group = info->explicit_group;
 
     if (group == 0)
         return true;
 
     if ((keyi->typesDefined | keyi->symsDefined | keyi->actsDefined) & ~1) {
-        int i;
+        xkb_group_index_t i;
         WARN("For the map %s an explicit group specified\n", info->name);
         WARN("but key %s has more than one group defined\n",
              longText(keyi->name));
@@ -1438,7 +1439,8 @@ static struct xkb_key *
 FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
 {
     struct xkb_key *key, *ret = NULL;
-    unsigned int group, level, min_group = UINT_MAX, min_level = UINT_MAX;
+    xkb_group_index_t group, min_group = UINT_MAX;
+    unsigned int level, min_level = UINT_MAX;
 
     xkb_foreach_key(key, keymap) {
         for (group = 0; group < key->num_groups; group++) {
@@ -1570,7 +1572,8 @@ FindAutomaticType(struct xkb_keymap *keymap, int width,
 static void
 PrepareKeyDef(KeyInfo *keyi)
 {
-    int i, j, width, defined, lastGroup;
+    xkb_group_index_t i, lastGroup;
+    int j, width, defined;
     bool identical;
 
     defined = keyi->symsDefined | keyi->actsDefined | keyi->typesDefined;
@@ -1679,13 +1682,14 @@ PrepareKeyDef(KeyInfo *keyi)
  * This function recurses.
  */
 static bool
-CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *keyi, int start_from)
+CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *keyi,
+               xkb_keycode_t start_from)
 {
-    unsigned int i;
     xkb_keycode_t kc;
     struct xkb_key *key;
-    unsigned int sizeSyms = 0;
-    unsigned width, tmp, nGroups;
+    size_t sizeSyms = 0;
+    xkb_group_index_t i, nGroups;
+    unsigned width, tmp;
     struct xkb_key_type * type;
     bool haveActions, autoType, useAlias;
     unsigned types[XkbNumKbdGroups];
@@ -1706,7 +1710,8 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *keyi, int start_from)
     kc = XkbKeyGetKeycode(keymap, key);
 
     haveActions = false;
-    for (i = width = nGroups = 0; i < XkbNumKbdGroups; i++) {
+    width = 0;
+    for (i = nGroups = 0; i < XkbNumKbdGroups; i++) {
         if (((i + 1) > nGroups)
             && (((keyi->symsDefined | keyi->actsDefined) & (1 << i))
                 || (keyi->typesDefined) & (1 << i)))
@@ -1724,7 +1729,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *keyi, int start_from)
             else {
                 if (warningLevel >= 5) {
                     WARN("No automatic type for %d symbols\n",
-                          (unsigned int) keyi->numLevels[i]);
+                          keyi->numLevels[i]);
                     ACTION("Using %s for the %s key (keycode %d)\n",
                             xkb_atom_text(keymap->ctx, keyi->types[i]),
                             longText(keyi->name), kc);
@@ -1892,7 +1897,7 @@ bool
 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
                enum merge_mode merge)
 {
-    int i;
+    xkb_group_index_t i;
     struct xkb_key *key;
     SymbolsInfo info;
     KeyInfo *keyi;