Fix NULL after deref issue detected by static analysis tool
[platform/upstream/libxkbcommon.git] / src / xkbcomp / symbols.c
index f693bae..58f73e6 100644 (file)
@@ -51,6 +51,8 @@
  *         Ran Benita <ran234@gmail.com>
  */
 
+#include "config.h"
+
 #include "xkbcomp-priv.h"
 #include "text.h"
 #include "expr.h"
@@ -59,6 +61,7 @@
 #include "include.h"
 #include "keysym.h"
 
+
 enum key_repeat {
     KEY_REPEAT_UNDEFINED = 0,
     KEY_REPEAT_YES = 1,
@@ -160,6 +163,8 @@ ClearKeyInfo(KeyInfo *keyi)
 typedef struct {
     enum merge_mode merge;
     bool haveSymbol;
+    // NOTE: Can also be XKB_MOD_NONE, meaning
+    //       “don’t add a modifier to the modmap”.
     xkb_mod_index_t modifier;
     union {
         xkb_atom_t keyName;
@@ -236,13 +241,15 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
             xkb_atom_t use = (clobber ? from->type : into->type);
             xkb_atom_t ignore = (clobber ? into->type : from->type);
 
-            if (report)
+            if (report) {
                 log_warn(info->ctx,
+                         XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS,
                          "Multiple definitions for group %d type of key %s; "
                          "Using %s, ignoring %s\n",
                          group + 1, KeyNameText(info->ctx, key_name),
                          xkb_atom_text(info->ctx, use),
                          xkb_atom_text(info->ctx, ignore));
+            }
 
             into->type = use;
         }
@@ -280,13 +287,15 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
             use = (clobber ? &fromLevel->action : &intoLevel->action);
             ignore = (clobber ? &intoLevel->action : &fromLevel->action);
 
-            if (report)
+            if (report) {
                 log_warn(info->ctx,
+                         XKB_WARNING_CONFLICTING_KEY_ACTION,
                          "Multiple actions for level %d/group %u on key %s; "
                          "Using %s, ignoring %s\n",
                          i + 1, group + 1, KeyNameText(info->ctx, key_name),
                          ActionTypeText(use->type),
                          ActionTypeText(ignore->type));
+            }
 
             intoLevel->action = *use;
         }
@@ -303,13 +312,15 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
             fromLevel->num_syms = 0;
         }
         else if (!XkbLevelsSameSyms(fromLevel, intoLevel)) {
-            if (report)
+            if (report) {
                 log_warn(info->ctx,
+                         XKB_WARNING_CONFLICTING_KEY_SYMBOL,
                          "Multiple symbols for level %d/group %u on key %s; "
                          "Using %s, ignoring %s\n",
                          i + 1, group + 1, KeyNameText(info->ctx, key_name),
                          (clobber ? "from" : "to"),
                          (clobber ? "to" : "from"));
+            }
 
             if (clobber) {
                 ClearLevelInfo(intoLevel);
@@ -402,12 +413,14 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from, bool same_file)
         into->defined |= KEY_FIELD_GROUPINFO;
     }
 
-    if (collide)
+    if (collide) {
         log_warn(info->ctx,
+                 XKB_WARNING_CONFLICTING_KEY_FIELDS,
                  "Symbol map for key %s redefined; "
                  "Using %s definition for conflicting fields\n",
                  KeyNameText(info->ctx, into->name),
                  (clobber ? "first" : "last"));
+    }
 
     ClearKeyInfo(from);
     InitKeyInfo(info->ctx, from);
@@ -460,21 +473,23 @@ AddModMapEntry(SymbolsInfo *info, ModMapEntry *new)
         use = (clobber ? new->modifier : old->modifier);
         ignore = (clobber ? old->modifier : new->modifier);
 
-        if (new->haveSymbol)
-            log_err(info->ctx,
-                    "Symbol \"%s\" added to modifier map for multiple modifiers; "
-                    "Using %s, ignoring %s\n",
-                    KeysymText(info->ctx, new->u.keySym),
-                    ModIndexText(info->ctx, &info->mods, use),
-                    ModIndexText(info->ctx, &info->mods, ignore));
-        else
-            log_err(info->ctx,
-                    "Key \"%s\" added to modifier map for multiple modifiers; "
-                    "Using %s, ignoring %s\n",
-                    KeyNameText(info->ctx, new->u.keyName),
-                    ModIndexText(info->ctx, &info->mods, use),
-                    ModIndexText(info->ctx, &info->mods, ignore));
-
+        if (new->haveSymbol) {
+            log_warn(info->ctx,
+                     XKB_WARNING_CONFLICTING_MODMAP,
+                     "Symbol \"%s\" added to modifier map for multiple modifiers; "
+                     "Using %s, ignoring %s\n",
+                     KeysymText(info->ctx, new->u.keySym),
+                     ModIndexText(info->ctx, &info->mods, use),
+                     ModIndexText(info->ctx, &info->mods, ignore));
+        } else {
+            log_warn(info->ctx,
+                     XKB_WARNING_CONFLICTING_MODMAP,
+                     "Key \"%s\" added to modifier map for multiple modifiers; "
+                     "Using %s, ignoring %s\n",
+                     KeyNameText(info->ctx, new->u.keyName),
+                     ModIndexText(info->ctx, &info->mods, use),
+                     ModIndexText(info->ctx, &info->mods, ignore));
+        }
         old->modifier = use;
         return true;
     }
@@ -554,6 +569,9 @@ HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *include)
 {
     SymbolsInfo included;
 
+    if (!include)
+        return false;
+
     InitSymbolsInfo(&included, info->keymap, info->actions, &info->mods);
     included.name = include->stmt;
     include->stmt = NULL;
@@ -575,6 +593,7 @@ HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *include)
             next_incl.explicit_group = atoi(stmt->modifier) - 1;
             if (next_incl.explicit_group >= XKB_MAX_GROUPS) {
                 log_err(info->ctx,
+                        XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
                         "Cannot set explicit group to %d - must be between 1..%d; "
                         "Ignoring group number\n",
                         next_incl.explicit_group + 1, XKB_MAX_GROUPS);
@@ -623,6 +642,7 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
 
         if (i >= XKB_MAX_GROUPS) {
             log_err(info->ctx,
+                    XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
                     "Too many groups of %s for key %s (max %u); "
                     "Ignoring %s defined for extra groups\n",
                     name, KeyInfoText(info, keyi), XKB_MAX_GROUPS, name);
@@ -635,7 +655,7 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
     }
 
     if (!ExprResolveGroup(info->ctx, arrayNdx, ndx_rtrn)) {
-        log_err(info->ctx,
+        log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
                 "Illegal group index for %s of key %s\n"
                 "Definition with non-integer array index ignored\n",
                 name, KeyInfoText(info, keyi));
@@ -669,6 +689,7 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
 
     if (value->expr.op != EXPR_KEYSYM_LIST) {
         log_err(info->ctx,
+                XKB_ERROR_WRONG_FIELD_TYPE,
                 "Expected a list of symbols, found %s; "
                 "Ignoring symbols for group %u of %s\n",
                 expr_op_type_to_string(value->expr.op), ndx + 1,
@@ -678,6 +699,7 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
 
     if (groupi->defined & GROUP_FIELD_SYMS) {
         log_err(info->ctx,
+                XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY,
                 "Symbols for key %s, group %u already defined; "
                 "Ignoring duplicate definition\n",
                 KeyInfoText(info, keyi), ndx + 1);
@@ -696,8 +718,13 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
 
         sym_index = darray_item(value->keysym_list.symsMapIndex, i);
         leveli->num_syms = darray_item(value->keysym_list.symsNumEntries, i);
-        if (leveli->num_syms > 1)
+        if (leveli->num_syms > 1) {
             leveli->u.syms = calloc(leveli->num_syms, sizeof(*leveli->u.syms));
+            if (!leveli->u.syms) {
+                log_err(info->ctx, "Failed to allocate memory for leveli->u.syms\n");
+                continue;
+            }
+        }
 
         for (unsigned j = 0; j < leveli->num_syms; j++) {
             xkb_keysym_t keysym = darray_item(value->keysym_list.syms,
@@ -738,7 +765,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
     }
 
     if (value->expr.op != EXPR_ACTION_LIST) {
-        log_wsgo(info->ctx,
+        log_wsgo(info->ctx, XKB_LOG_MESSAGE_NO_ID,
                  "Bad expression type (%d) for action list value; "
                  "Ignoring actions for group %u of %s\n",
                  value->expr.op, ndx, KeyInfoText(info, keyi));
@@ -746,14 +773,14 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
     }
 
     if (groupi->defined & GROUP_FIELD_ACTS) {
-        log_wsgo(info->ctx,
+        log_wsgo(info->ctx, XKB_LOG_MESSAGE_NO_ID,
                  "Actions for key %s, group %u already defined\n",
                  KeyInfoText(info, keyi), ndx);
         return false;
     }
 
     nActs = 0;
-    for (act = value->unary.child; act; act = (ExprDef *) act->common.next)
+    for (act = value->actions.actions; act; act = (ExprDef *) act->common.next)
         nActs++;
 
     if (darray_size(groupi->levels) < nActs)
@@ -761,12 +788,13 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
 
     groupi->defined |= GROUP_FIELD_ACTS;
 
-    act = value->unary.child;
+    act = value->actions.actions;
     for (unsigned i = 0; i < nActs; i++) {
         union xkb_action *toAct = &darray_item(groupi->levels, i).action;
 
         if (!HandleActionDef(info->ctx, info->actions, &info->mods, act, toAct))
             log_err(info->ctx,
+                    XKB_ERROR_INVALID_VALUE,
                     "Illegal action definition for %s; "
                     "Action for group %u/level %u ignored\n",
                     KeyInfoText(info, keyi), ndx + 1, i + 1);
@@ -798,6 +826,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
 
         if (!ExprResolveString(info->ctx, value, &val)) {
             log_err(info->ctx,
+                    XKB_ERROR_WRONG_FIELD_TYPE,
                     "The type field of a key symbol map must be a string; "
                     "Ignoring illegal type definition\n");
             return false;
@@ -808,7 +837,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
             keyi->defined |= KEY_FIELD_DEFAULT_TYPE;
         }
         else if (!ExprResolveGroup(info->ctx, arrayNdx, &ndx)) {
-            log_err(info->ctx,
+            log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
                     "Illegal group index for type of key %s; "
                     "Definition with non-integer array index ignored\n",
                     KeyInfoText(info, keyi));
@@ -836,6 +865,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         if (!ExprResolveModMask(info->ctx, value, MOD_VIRT, &info->mods,
                                 &mask)) {
             log_err(info->ctx,
+                    XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
                     "Expected a virtual modifier mask, found %s; "
                     "Ignoring virtual modifiers definition for key %s\n",
                     expr_op_type_to_string(value->expr.op),
@@ -850,6 +880,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
              istreq(field, "lock") ||
              istreq(field, "locks")) {
         log_vrb(info->ctx, 1,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Key behaviors not supported; "
                 "Ignoring locking specification for key %s\n",
                 KeyInfoText(info, keyi));
@@ -858,6 +889,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
              istreq(field, "permanentradiogroup") ||
              istreq(field, "allownone")) {
         log_vrb(info->ctx, 1,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Radio groups not supported; "
                 "Ignoring radio group specification for key %s\n",
                 KeyInfoText(info, keyi));
@@ -865,6 +897,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
     else if (istreq_prefix("overlay", field) ||
              istreq_prefix("permanentoverlay", field)) {
         log_vrb(info->ctx, 1,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Overlays not supported; "
                 "Ignoring overlay specification for key %s\n",
                 KeyInfoText(info, keyi));
@@ -876,6 +909,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
 
         if (!ExprResolveEnum(info->ctx, value, &val, repeatEntries)) {
             log_err(info->ctx,
+                    XKB_ERROR_INVALID_VALUE,
                     "Illegal repeat setting for %s; "
                     "Non-boolean repeat setting ignored\n",
                     KeyInfoText(info, keyi));
@@ -891,6 +925,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
 
         if (!ExprResolveBoolean(info->ctx, value, &set)) {
             log_err(info->ctx,
+                    XKB_ERROR_INVALID_VALUE,
                     "Illegal groupsWrap setting for %s; "
                     "Non-boolean value ignored\n",
                     KeyInfoText(info, keyi));
@@ -906,6 +941,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
 
         if (!ExprResolveBoolean(info->ctx, value, &set)) {
             log_err(info->ctx,
+                    XKB_ERROR_INVALID_VALUE,
                     "Illegal groupsClamp setting for %s; "
                     "Non-boolean value ignored\n",
                     KeyInfoText(info, keyi));
@@ -920,7 +956,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         xkb_layout_index_t grp;
 
         if (!ExprResolveGroup(info->ctx, value, &grp)) {
-            log_err(info->ctx,
+            log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
                     "Illegal group index for redirect of key %s; "
                     "Definition with non-integer group ignored\n",
                     KeyInfoText(info, keyi));
@@ -933,6 +969,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
     }
     else {
         log_err(info->ctx,
+                XKB_ERROR_UNKNOWN_FIELD,
                 "Unknown field %s in a symbol interpretation; "
                 "Definition ignored\n",
                 field);
@@ -950,13 +987,14 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
 
     if (!arrayNdx) {
         log_vrb(info->ctx, 1,
+                XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX,
                 "You must specify an index when specifying a group name; "
                 "Group name definition without array subscript ignored\n");
         return false;
     }
 
     if (!ExprResolveGroup(info->ctx, arrayNdx, &group)) {
-        log_err(info->ctx,
+        log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
                 "Illegal index in group name definition; "
                 "Definition with non-integer array index ignored\n");
         return false;
@@ -964,6 +1002,7 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
 
     if (!ExprResolveString(info->ctx, value, &name)) {
         log_err(info->ctx,
+                XKB_ERROR_WRONG_FIELD_TYPE,
                 "Group name must be a string; "
                 "Illegal name for group %d ignored\n", group);
         return false;
@@ -977,6 +1016,7 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
     }
     else {
         log_warn(info->ctx,
+                 XKB_WARNING_NON_BASE_GROUP_NAME,
                  "An explicit group was specified for the '%s' map, "
                  "but it provides a name for a group other than Group1 (%d); "
                  "Ignoring group name '%s'\n",
@@ -1013,23 +1053,27 @@ HandleGlobalVar(SymbolsInfo *info, VarDef *stmt)
     else if (!elem && (istreq(field, "groupswrap") ||
                        istreq(field, "wrapgroups"))) {
         log_err(info->ctx,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Global \"groupswrap\" not supported; Ignored\n");
         ret = true;
     }
     else if (!elem && (istreq(field, "groupsclamp") ||
                        istreq(field, "clampgroups"))) {
         log_err(info->ctx,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Global \"groupsclamp\" not supported; Ignored\n");
         ret = true;
     }
     else if (!elem && (istreq(field, "groupsredirect") ||
                        istreq(field, "redirectgroups"))) {
         log_err(info->ctx,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Global \"groupsredirect\" not supported; Ignored\n");
         ret = true;
     }
     else if (!elem && istreq(field, "allownone")) {
         log_err(info->ctx,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Radio groups not supported; "
                 "Ignoring \"allownone\" specification\n");
         ret = true;
@@ -1052,6 +1096,7 @@ HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
     for (; def; def = (VarDef *) def->common.next) {
         if (def->name && def->name->expr.op == EXPR_FIELD_REF) {
             log_err(info->ctx,
+                    XKB_ERROR_WRONG_SCOPE,
                     "Cannot set a global default value from within a key statement; "
                     "Move statements to the global file scope\n");
             continue;
@@ -1094,12 +1139,14 @@ SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
         }
     }
 
-    if (warn)
+    if (warn) {
         log_warn(info->ctx,
+                 XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE,
                  "For the map %s an explicit group specified, "
                  "but key %s has more than one group defined; "
                  "All groups except first one will be ignored\n",
                  info->name, KeyInfoText(info, keyi));
+    }
 
     darray_resize0(keyi->groups, info->explicit_group + 1);
     if (info->explicit_group > 0) {
@@ -1150,14 +1197,22 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
     xkb_mod_index_t ndx;
     bool ok;
     struct xkb_context *ctx = info->ctx;
-
-    ndx = XkbModNameToIndex(&info->mods, def->modifier, MOD_REAL);
-    if (ndx == XKB_MOD_INVALID) {
-        log_err(info->ctx,
-                "Illegal modifier map definition; "
-                "Ignoring map for non-modifier \"%s\"\n",
-                xkb_atom_text(ctx, def->modifier));
-        return false;
+    const char *modifier_name = xkb_atom_text(ctx, def->modifier);
+
+    if (istreq(modifier_name, "none")) {
+        // Handle special "None" entry
+        ndx = XKB_MOD_NONE;
+    } else {
+        // Handle normal entry
+        ndx = XkbModNameToIndex(&info->mods, def->modifier, MOD_REAL);
+        if (ndx == XKB_MOD_INVALID) {
+            log_err(info->ctx,
+                    XKB_ERROR_INVALID_REAL_MODIFIER,
+                    "Illegal modifier map definition; "
+                    "Ignoring map for non-modifier \"%s\"\n",
+                    xkb_atom_text(ctx, def->modifier));
+            return false;
+        }
     }
 
     ok = true;
@@ -1178,6 +1233,7 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
         }
         else {
             log_err(info->ctx,
+                    XKB_ERROR_INVALID_MODMAP_ENTRY,
                     "Modmap entries may contain only key names or keysyms; "
                     "Illegal definition for %s modifier ignored\n",
                     ModIndexText(info->ctx, &info->mods, tmp.modifier));
@@ -1216,6 +1272,7 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
             break;
         default:
             log_err(info->ctx,
+                    XKB_ERROR_WRONG_STATEMENT_TYPE,
                     "Symbols files may not include other types; "
                     "Ignoring %s\n", stmt_type_to_string(stmt->type));
             ok = false;
@@ -1226,7 +1283,9 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
             info->errorCount++;
 
         if (info->errorCount > 10) {
-            log_err(info->ctx, "Abandoning symbols file \"%s\"\n",
+            log_err(info->ctx,
+                    XKB_ERROR_INVALID_SYNTAX,
+                    "Abandoning symbols file \"%s\"\n",
                     file->name);
             break;
         }
@@ -1361,6 +1420,7 @@ FindTypeForGroup(struct xkb_keymap *keymap, KeyInfo *keyi,
 
     if (type_name == XKB_ATOM_NONE) {
         log_warn(keymap->ctx,
+                 XKB_WARNING_CANNOT_INFER_KEY_TYPE,
                  "Couldn't find an automatic type for key '%s' group %d with %lu levels; "
                  "Using the default type\n",
                  KeyNameText(keymap->ctx, keyi->name), group + 1,
@@ -1374,6 +1434,7 @@ FindTypeForGroup(struct xkb_keymap *keymap, KeyInfo *keyi,
 
     if (i >= keymap->num_types) {
         log_warn(keymap->ctx,
+                 XKB_WARNING_UNDEFINED_KEY_TYPE,
                  "The type \"%s\" for key '%s' group %d was not previously defined; "
                  "Using the default type\n",
                  xkb_atom_text(keymap->ctx, type_name),
@@ -1407,6 +1468,7 @@ CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
     key = XkbKeyByName(keymap, keyi->name, false);
     if (!key) {
         log_vrb(info->ctx, 5,
+                XKB_WARNING_UNDEFINED_KEYCODE,
                 "Key %s not found in keycodes; Symbols ignored\n",
                 KeyInfoText(info, keyi));
         return false;
@@ -1437,6 +1499,10 @@ CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
     }
 
     key->groups = calloc(key->num_groups, sizeof(*key->groups));
+    if (!key->groups) {
+        log_err(info->ctx, "Failed to allocate memory for key->groups\n");
+        return false;
+    }
 
     /* Find and assign the groups' types in the keymap. */
     darray_enumerate(i, groupi, keyi->groups) {
@@ -1450,6 +1516,7 @@ CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
             struct xkb_level *leveli;
 
             log_vrb(info->ctx, 1,
+                    XKB_WARNING_EXTRA_SYMBOLS_IGNORED,
                     "Type \"%s\" has %d levels, but %s has %d levels; "
                     "Ignoring extra symbols\n",
                     xkb_atom_text(keymap->ctx, type->name), type->num_levels,
@@ -1502,6 +1569,7 @@ CopyModMapDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
         key = XkbKeyByName(keymap, entry->u.keyName, true);
         if (!key) {
             log_vrb(info->ctx, 5,
+                    XKB_WARNING_UNDEFINED_KEYCODE,
                     "Key %s not found in keycodes; "
                     "Modifier map entry for %s not updated\n",
                     KeyNameText(info->ctx, entry->u.keyName),
@@ -1513,6 +1581,7 @@ CopyModMapDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
         key = FindKeyForSymbol(keymap, entry->u.keySym);
         if (!key) {
             log_vrb(info->ctx, 5,
+                    XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL,
                     "Key \"%s\" not found in symbol map; "
                     "Modifier map entry for %s not updated\n",
                     KeysymText(info->ctx, entry->u.keySym),
@@ -1521,7 +1590,12 @@ CopyModMapDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
         }
     }
 
-    key->modmap |= (1u << entry->modifier);
+    // Handle modMap None
+    if (entry->modifier != XKB_MOD_NONE) {
+        // Convert modifier index to modifier mask
+        key->modmap |= (1u << entry->modifier);
+    }
+
     return true;
 }
 
@@ -1551,7 +1625,7 @@ CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
                 continue;
 
             if (key->num_groups < 1)
-                log_info(info->ctx,
+                log_info(info->ctx, XKB_LOG_MESSAGE_NO_ID,
                          "No symbols defined for %s\n",
                          KeyNameText(info->ctx, key->name));
         }