e8e82df44f1838f974f8c60fbd58662fcb69f311
[platform/upstream/libxkbcommon.git] / src / xkbcomp / types.c
1 /************************************************************
2  * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
3  *
4  * Permission to use, copy, modify, and distribute this
5  * software and its documentation for any purpose and without
6  * fee is hereby granted, provided that the above copyright
7  * notice appear in all copies and that both that copyright
8  * notice and this permission notice appear in supporting
9  * documentation, and that the name of Silicon Graphics not be
10  * used in advertising or publicity pertaining to distribution
11  * of the software without specific prior written permission.
12  * Silicon Graphics makes no representation about the suitability
13  * of this software for any purpose. It is provided "as is"
14  * without any express or implied warranty.
15  *
16  * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18  * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19  * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
24  *
25  ********************************************************/
26
27 #include "config.h"
28
29 #include "xkbcomp-priv.h"
30 #include "text.h"
31 #include "vmod.h"
32 #include "expr.h"
33 #include "include.h"
34
35 enum type_field {
36     TYPE_FIELD_MASK = (1 << 0),
37     TYPE_FIELD_MAP = (1 << 1),
38     TYPE_FIELD_PRESERVE = (1 << 2),
39     TYPE_FIELD_LEVEL_NAME = (1 << 3),
40 };
41
42 typedef struct {
43     enum type_field defined;
44     enum merge_mode merge;
45
46     xkb_atom_t name;
47     xkb_mod_mask_t mods;
48     xkb_level_index_t num_levels;
49     darray(struct xkb_key_type_entry) entries;
50     darray(xkb_atom_t) level_names;
51 } KeyTypeInfo;
52
53 typedef struct {
54     char *name;
55     int errorCount;
56
57     darray(KeyTypeInfo) types;
58     struct xkb_mod_set mods;
59
60     struct xkb_context *ctx;
61 } KeyTypesInfo;
62
63 /***====================================================================***/
64
65 static inline const char *
66 MapEntryTxt(KeyTypesInfo *info, struct xkb_key_type_entry *entry)
67 {
68     return ModMaskText(info->ctx, &info->mods, entry->mods.mods);
69 }
70
71 static inline const char *
72 TypeTxt(KeyTypesInfo *info, KeyTypeInfo *type)
73 {
74     return xkb_atom_text(info->ctx, type->name);
75 }
76
77 static inline const char *
78 TypeMaskTxt(KeyTypesInfo *info, KeyTypeInfo *type)
79 {
80     return ModMaskText(info->ctx, &info->mods, type->mods);
81 }
82
83 static inline bool
84 ReportTypeShouldBeArray(KeyTypesInfo *info, KeyTypeInfo *type,
85                         const char *field)
86 {
87     return ReportShouldBeArray(info->ctx, "key type", field,
88                                TypeTxt(info, type));
89 }
90
91 static inline bool
92 ReportTypeBadType(KeyTypesInfo *info, xkb_message_code_t code,
93                   KeyTypeInfo *type, const char *field, const char *wanted)
94 {
95     return ReportBadType(info->ctx, code, "key type", field,
96                          TypeTxt(info, type), wanted);
97 }
98
99 /***====================================================================***/
100
101 static void
102 InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_context *ctx,
103                  const struct xkb_mod_set *mods)
104 {
105     memset(info, 0, sizeof(*info));
106     info->ctx = ctx;
107     info->mods = *mods;
108 }
109
110 static void
111 ClearKeyTypeInfo(KeyTypeInfo *type)
112 {
113     darray_free(type->entries);
114     darray_free(type->level_names);
115 }
116
117 static void
118 ClearKeyTypesInfo(KeyTypesInfo *info)
119 {
120     free(info->name);
121     darray_free(info->types);
122 }
123
124 static KeyTypeInfo *
125 FindMatchingKeyType(KeyTypesInfo *info, xkb_atom_t name)
126 {
127     KeyTypeInfo *old;
128
129     darray_foreach(old, info->types)
130         if (old->name == name)
131             return old;
132
133     return NULL;
134 }
135
136 static bool
137 AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new, bool same_file)
138 {
139     KeyTypeInfo *old;
140     const int verbosity = xkb_context_get_log_verbosity(info->ctx);
141
142     old = FindMatchingKeyType(info, new->name);
143     if (old) {
144         if (new->merge == MERGE_REPLACE || new->merge == MERGE_OVERRIDE) {
145             if ((same_file && verbosity > 0) || verbosity > 9) {
146                 log_warn(info->ctx,
147                          "Multiple definitions of the %s key type; "
148                          "Earlier definition ignored\n",
149                          xkb_atom_text(info->ctx, new->name));
150             }
151
152             ClearKeyTypeInfo(old);
153             *old = *new;
154             darray_init(new->entries);
155             darray_init(new->level_names);
156             return true;
157         }
158
159         if (same_file)
160             log_vrb(info->ctx, 4,
161                     "Multiple definitions of the %s key type; "
162                     "Later definition ignored\n",
163                     xkb_atom_text(info->ctx, new->name));
164
165         ClearKeyTypeInfo(new);
166         return true;
167     }
168
169     darray_append(info->types, *new);
170     return true;
171 }
172
173 /***====================================================================***/
174
175 static void
176 MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
177                       enum merge_mode merge)
178 {
179     if (from->errorCount > 0) {
180         into->errorCount += from->errorCount;
181         return;
182     }
183
184     into->mods = from->mods;
185
186     if (into->name == NULL) {
187         into->name = from->name;
188         from->name = NULL;
189     }
190
191     if (darray_empty(into->types)) {
192         into->types = from->types;
193         darray_init(from->types);
194     }
195     else {
196         KeyTypeInfo *type;
197         darray_foreach(type, from->types) {
198             type->merge = (merge == MERGE_DEFAULT ? type->merge : merge);
199             if (!AddKeyType(into, type, false))
200                 into->errorCount++;
201         }
202     }
203 }
204
205 static void
206 HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge);
207
208 static bool
209 HandleIncludeKeyTypes(KeyTypesInfo *info, IncludeStmt *include)
210 {
211     KeyTypesInfo included;
212
213     InitKeyTypesInfo(&included, info->ctx, &info->mods);
214     included.name = include->stmt;
215     include->stmt = NULL;
216
217     for (IncludeStmt *stmt = include; stmt; stmt = stmt->next_incl) {
218         KeyTypesInfo next_incl;
219         XkbFile *file;
220
221         file = ProcessIncludeFile(info->ctx, stmt, FILE_TYPE_TYPES);
222         if (!file) {
223             info->errorCount += 10;
224             ClearKeyTypesInfo(&included);
225             return false;
226         }
227
228         InitKeyTypesInfo(&next_incl, info->ctx, &included.mods);
229
230         HandleKeyTypesFile(&next_incl, file, stmt->merge);
231
232         MergeIncludedKeyTypes(&included, &next_incl, stmt->merge);
233
234         ClearKeyTypesInfo(&next_incl);
235         FreeXkbFile(file);
236     }
237
238     MergeIncludedKeyTypes(info, &included, include->merge);
239     ClearKeyTypesInfo(&included);
240
241     return (info->errorCount == 0);
242 }
243
244 /***====================================================================***/
245
246 static bool
247 SetModifiers(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
248              ExprDef *value)
249 {
250     xkb_mod_mask_t mods;
251
252     if (arrayNdx)
253         log_warn(info->ctx,
254                  "The modifiers field of a key type is not an array; "
255                  "Illegal array subscript ignored\n");
256
257     if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods, &mods)) {
258         log_err(info->ctx,
259                 "Key type mask field must be a modifier mask; "
260                 "Key type definition ignored\n");
261         return false;
262     }
263
264     if (type->defined & TYPE_FIELD_MASK) {
265         log_warn(info->ctx,
266                  "Multiple modifier mask definitions for key type %s; "
267                  "Using %s, ignoring %s\n",
268                  xkb_atom_text(info->ctx, type->name),
269                  TypeMaskTxt(info, type),
270                  ModMaskText(info->ctx, &info->mods, mods));
271         return false;
272     }
273
274     type->mods = mods;
275     return true;
276 }
277
278 /***====================================================================***/
279
280 static struct xkb_key_type_entry *
281 FindMatchingMapEntry(KeyTypeInfo *type, xkb_mod_mask_t mods)
282 {
283     struct xkb_key_type_entry *entry;
284
285     darray_foreach(entry, type->entries)
286         if (entry->mods.mods == mods)
287             return entry;
288
289     return NULL;
290 }
291
292 static bool
293 AddMapEntry(KeyTypesInfo *info, KeyTypeInfo *type,
294             struct xkb_key_type_entry *new, bool clobber, bool report)
295 {
296     struct xkb_key_type_entry *old;
297
298     old = FindMatchingMapEntry(type, new->mods.mods);
299     if (old) {
300         if (report && old->level != new->level) {
301             log_warn(info->ctx,
302                      "Multiple map entries for %s in %s; "
303                      "Using %d, ignoring %d\n",
304                      MapEntryTxt(info, new), TypeTxt(info, type),
305                      (clobber ? new->level : old->level) + 1,
306                      (clobber ? old->level : new->level) + 1);
307         }
308         else {
309             log_vrb(info->ctx, 10,
310                     "Multiple occurrences of map[%s]= %d in %s; Ignored\n",
311                     MapEntryTxt(info, new), new->level + 1,
312                     TypeTxt(info, type));
313             return true;
314         }
315
316         if (clobber) {
317             if (new->level >= type->num_levels)
318                 type->num_levels = new->level + 1;
319             old->level = new->level;
320         }
321
322         return true;
323     }
324
325     if (new->level >= type->num_levels)
326         type->num_levels = new->level + 1;
327
328     darray_append(type->entries, *new);
329     return true;
330 }
331
332 static bool
333 SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
334             ExprDef *value)
335 {
336     struct xkb_key_type_entry entry;
337
338     if (arrayNdx == NULL)
339         return ReportTypeShouldBeArray(info, type, "map entry");
340
341     if (!ExprResolveModMask(info->ctx, arrayNdx, MOD_BOTH, &info->mods,
342                             &entry.mods.mods))
343         return ReportTypeBadType(info, XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
344                                  type, "map entry", "modifier mask");
345
346     if (entry.mods.mods & (~type->mods)) {
347         log_vrb(info->ctx, 1,
348                 "Map entry for unused modifiers in %s; "
349                 "Using %s instead of %s\n",
350                 TypeTxt(info, type),
351                 ModMaskText(info->ctx, &info->mods,
352                             entry.mods.mods & type->mods),
353                 MapEntryTxt(info, &entry));
354         entry.mods.mods &= type->mods;
355     }
356
357     if (!ExprResolveLevel(info->ctx, value, &entry.level)) {
358         log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL,
359                           "Level specifications in a key type must be integer; "
360                           "Ignoring malformed level specification\n");
361         return false;
362     }
363
364     entry.preserve.mods = 0;
365
366     return AddMapEntry(info, type, &entry, true, true);
367 }
368
369 /***====================================================================***/
370
371 static bool
372 AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type,
373             xkb_mod_mask_t mods, xkb_mod_mask_t preserve_mods)
374 {
375     struct xkb_key_type_entry *entry;
376     struct xkb_key_type_entry new;
377
378     darray_foreach(entry, type->entries) {
379         if (entry->mods.mods != mods)
380             continue;
381
382         /* Map exists without previous preserve (or "None"); override. */
383         if (entry->preserve.mods == 0) {
384             entry->preserve.mods = preserve_mods;
385             return true;
386         }
387
388         /* Map exists with same preserve; do nothing. */
389         if (entry->preserve.mods == preserve_mods) {
390             log_vrb(info->ctx, 10,
391                     "Identical definitions for preserve[%s] in %s; "
392                     "Ignored\n",
393                     ModMaskText(info->ctx, &info->mods, mods),
394                     TypeTxt(info, type));
395             return true;
396         }
397
398         /* Map exists with different preserve; latter wins. */
399         log_vrb(info->ctx, 1,
400                 "Multiple definitions for preserve[%s] in %s; "
401                 "Using %s, ignoring %s\n",
402                 ModMaskText(info->ctx, &info->mods, mods),
403                 TypeTxt(info, type),
404                 ModMaskText(info->ctx, &info->mods, preserve_mods),
405                 ModMaskText(info->ctx, &info->mods, entry->preserve.mods));
406
407         entry->preserve.mods = preserve_mods;
408         return true;
409     }
410
411     /*
412      * Map does not exist, i.e. preserve[] came before map[].
413      * Create a map with the specified mask mapping to Level1. The level
414      * may be overridden later with an explicit map[] statement.
415      */
416     new.level = 0;
417     new.mods.mods = mods;
418     new.preserve.mods = preserve_mods;
419     darray_append(type->entries, new);
420     return true;
421 }
422
423 static bool
424 SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
425             ExprDef *value)
426 {
427     xkb_mod_mask_t mods, preserve_mods;
428
429     if (arrayNdx == NULL)
430         return ReportTypeShouldBeArray(info, type, "preserve entry");
431
432     if (!ExprResolveModMask(info->ctx, arrayNdx, MOD_BOTH, &info->mods, &mods))
433         return ReportTypeBadType(info, XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
434                                  type, "preserve entry", "modifier mask");
435
436     if (mods & ~type->mods) {
437         const char *before, *after;
438
439         before = ModMaskText(info->ctx, &info->mods, mods);
440         mods &= type->mods;
441         after = ModMaskText(info->ctx, &info->mods, mods);
442
443         log_vrb(info->ctx, 1,
444                 "Preserve for modifiers not used by the %s type; "
445                 "Index %s converted to %s\n",
446                 TypeTxt(info, type), before, after);
447     }
448
449     if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods,
450                             &preserve_mods)) {
451         log_err(info->ctx,
452                 "Preserve value in a key type is not a modifier mask; "
453                 "Ignoring preserve[%s] in type %s\n",
454                 ModMaskText(info->ctx, &info->mods, mods),
455                 TypeTxt(info, type));
456         return false;
457     }
458
459     if (preserve_mods & ~mods) {
460         const char *before, *after;
461
462         before = ModMaskText(info->ctx, &info->mods, preserve_mods);
463         preserve_mods &= mods;
464         after = ModMaskText(info->ctx, &info->mods, preserve_mods);
465
466         log_vrb(info->ctx, 1,
467                 "Illegal value for preserve[%s] in type %s; "
468                 "Converted %s to %s\n",
469                 ModMaskText(info->ctx, &info->mods, mods),
470                 TypeTxt(info, type), before, after);
471     }
472
473     return AddPreserve(info, type, mods, preserve_mods);
474 }
475
476 /***====================================================================***/
477
478 static bool
479 AddLevelName(KeyTypesInfo *info, KeyTypeInfo *type,
480              xkb_level_index_t level, xkb_atom_t name, bool clobber)
481 {
482     /* New name. */
483     if (level >= darray_size(type->level_names)) {
484         darray_resize0(type->level_names, level + 1);
485         goto finish;
486     }
487
488     /* Same level, same name. */
489     if (darray_item(type->level_names, level) == name) {
490         log_vrb(info->ctx, 10,
491                 "Duplicate names for level %d of key type %s; Ignored\n",
492                 level + 1, TypeTxt(info, type));
493         return true;
494     }
495
496     /* Same level, different name. */
497     if (darray_item(type->level_names, level) != XKB_ATOM_NONE) {
498         const char *old, *new;
499         old = xkb_atom_text(info->ctx,
500                             darray_item(type->level_names, level));
501         new = xkb_atom_text(info->ctx, name);
502         log_vrb(info->ctx, 1,
503                 "Multiple names for level %d of key type %s; "
504                 "Using %s, ignoring %s\n",
505                 level + 1, TypeTxt(info, type),
506                 (clobber ? new : old), (clobber ? old : new));
507
508         if (!clobber)
509             return true;
510     }
511
512     /* XXX: What about different level, same name? */
513
514 finish:
515     darray_item(type->level_names, level) = name;
516     return true;
517 }
518
519 static bool
520 SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
521              ExprDef *value)
522 {
523     xkb_level_index_t level;
524     xkb_atom_t level_name;
525
526     if (arrayNdx == NULL)
527         return ReportTypeShouldBeArray(info, type, "level name");
528
529     if (!ExprResolveLevel(info->ctx, arrayNdx, &level))
530         return ReportTypeBadType(info, XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL,
531                                  type, "level name", "integer");
532
533     if (!ExprResolveString(info->ctx, value, &level_name)) {
534         log_err(info->ctx,
535                 "Non-string name for level %d in key type %s; "
536                 "Ignoring illegal level name definition\n",
537                 level + 1, xkb_atom_text(info->ctx, type->name));
538         return false;
539     }
540
541     return AddLevelName(info, type, level, level_name, true);
542 }
543
544 /***====================================================================***/
545
546 static bool
547 SetKeyTypeField(KeyTypesInfo *info, KeyTypeInfo *type,
548                 const char *field, ExprDef *arrayNdx, ExprDef *value)
549 {
550     bool ok = false;
551     enum type_field type_field = 0;
552
553     if (istreq(field, "modifiers")) {
554         type_field = TYPE_FIELD_MASK;
555         ok = SetModifiers(info, type, arrayNdx, value);
556     }
557     else if (istreq(field, "map")) {
558         type_field = TYPE_FIELD_MAP;
559         ok = SetMapEntry(info, type, arrayNdx, value);
560     }
561     else if (istreq(field, "preserve")) {
562         type_field = TYPE_FIELD_PRESERVE;
563         ok = SetPreserve(info, type, arrayNdx, value);
564     }
565     else if (istreq(field, "levelname") || istreq(field, "level_name")) {
566         type_field = TYPE_FIELD_LEVEL_NAME;
567         ok = SetLevelName(info, type, arrayNdx, value);
568     } else {
569         log_err(info->ctx,
570                 "Unknown field %s in key type %s; Definition ignored\n",
571                 field, TypeTxt(info, type));
572     }
573
574     type->defined |= type_field;
575     return ok;
576 }
577
578 static bool
579 HandleKeyTypeBody(KeyTypesInfo *info, VarDef *def, KeyTypeInfo *type)
580 {
581     bool ok = true;
582     const char *elem, *field;
583     ExprDef *arrayNdx;
584
585     for (; def; def = (VarDef *) def->common.next) {
586         ok = ExprResolveLhs(info->ctx, def->name, &elem, &field,
587                             &arrayNdx);
588         if (!ok)
589             continue;
590
591         if (elem && istreq(elem, "type")) {
592             log_err(info->ctx,
593                     "Support for changing the default type has been removed; "
594                     "Statement ignored\n");
595             continue;
596         }
597
598         ok = SetKeyTypeField(info, type, field, arrayNdx, def->value);
599     }
600
601     return ok;
602 }
603
604 static bool
605 HandleKeyTypeDef(KeyTypesInfo *info, KeyTypeDef *def, enum merge_mode merge)
606 {
607     KeyTypeInfo type = {
608         .defined = 0,
609         .merge = (def->merge == MERGE_DEFAULT ? merge : def->merge),
610         .name = def->name,
611         .mods = 0,
612         .num_levels = 1,
613         .entries = darray_new(),
614         .level_names = darray_new(),
615     };
616
617     if (!HandleKeyTypeBody(info, def->body, &type)) {
618         info->errorCount++;
619         return false;
620     }
621
622     if (!AddKeyType(info, &type, true)) {
623         info->errorCount++;
624         return false;
625     }
626
627     return true;
628 }
629
630 static void
631 HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge)
632 {
633     bool ok;
634
635     free(info->name);
636     info->name = strdup_safe(file->name);
637
638     for (ParseCommon *stmt = file->defs; stmt; stmt = stmt->next) {
639         switch (stmt->type) {
640         case STMT_INCLUDE:
641             ok = HandleIncludeKeyTypes(info, (IncludeStmt *) stmt);
642             break;
643         case STMT_TYPE:
644             ok = HandleKeyTypeDef(info, (KeyTypeDef *) stmt, merge);
645             break;
646         case STMT_VAR:
647             log_err(info->ctx,
648                     "Support for changing the default type has been removed; "
649                     "Statement ignored\n");
650             ok = true;
651             break;
652         case STMT_VMOD:
653             ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge);
654             break;
655         default:
656             log_err(info->ctx,
657                     "Key type files may not include other declarations; "
658                     "Ignoring %s\n", stmt_type_to_string(stmt->type));
659             ok = false;
660             break;
661         }
662
663         if (!ok)
664             info->errorCount++;
665
666         if (info->errorCount > 10) {
667             log_err(info->ctx,
668                     "Abandoning keytypes file \"%s\"\n", file->name);
669             break;
670         }
671     }
672 }
673
674 /***====================================================================***/
675
676 static bool
677 CopyKeyTypesToKeymap(struct xkb_keymap *keymap, KeyTypesInfo *info)
678 {
679     unsigned num_types;
680     struct xkb_key_type *types;
681
682     num_types = darray_empty(info->types) ? 1 : darray_size(info->types);
683     types = calloc(num_types, sizeof(*types));
684     if (!types)
685         return false;
686
687     /*
688      * If no types were specified, a default unnamed one-level type is
689      * used for all keys.
690      */
691     if (darray_empty(info->types)) {
692         struct xkb_key_type *type = &types[0];
693
694         type->mods.mods = 0;
695         type->num_levels = 1;
696         type->entries = NULL;
697         type->num_entries = 0;
698         type->name = xkb_atom_intern_literal(keymap->ctx, "default");
699         type->level_names = NULL;
700         type->num_level_names = 0;
701     }
702     else {
703         for (unsigned i = 0; i < num_types; i++) {
704             KeyTypeInfo *def = &darray_item(info->types, i);
705             struct xkb_key_type *type = &types[i];
706
707             type->name = def->name;
708             type->mods.mods = def->mods;
709             type->num_levels = def->num_levels;
710             darray_steal(def->level_names, &type->level_names, &type->num_level_names);
711             darray_steal(def->entries, &type->entries, &type->num_entries);
712         }
713     }
714
715     keymap->types_section_name = strdup_safe(info->name);
716     XkbEscapeMapName(keymap->types_section_name);
717     keymap->num_types = num_types;
718     keymap->types = types;
719     keymap->mods = info->mods;
720     return true;
721 }
722
723 /***====================================================================***/
724
725 bool
726 CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap,
727                 enum merge_mode merge)
728 {
729     KeyTypesInfo info;
730
731     InitKeyTypesInfo(&info, keymap->ctx, &keymap->mods);
732
733     HandleKeyTypesFile(&info, file, merge);
734     if (info.errorCount != 0)
735         goto err_info;
736
737     if (!CopyKeyTypesToKeymap(keymap, &info))
738         goto err_info;
739
740     ClearKeyTypesInfo(&info);
741     return true;
742
743 err_info:
744     ClearKeyTypesInfo(&info);
745     return false;
746 }