Fix issues detected by static analysis tool
[platform/upstream/libxkbcommon.git] / tools / messages.c
1 /*
2  * NOTE: This file has been generated automatically by “update-message-registry.py”.
3  *       Do not edit manually!
4  *
5  */
6
7 /*
8  * Copyright © 2023 Pierre Le Marre <dev@wismill.eu>
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice (including the next
18  * paragraph) shall be included in all copies or substantial portions of the
19  * Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  */
29
30 #include "config.h"
31
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35
36 #include "messages-codes.h"
37 #include "messages.h"
38 #include "utils.h"
39
40 static const struct xkb_message_entry xkb_messages[] = {
41     {XKB_ERROR_MALFORMED_NUMBER_LITERAL, "Malformed number literal"},
42     {XKB_WARNING_CONFLICTING_KEY_TYPE_PRESERVE_ENTRIES, "Conflicting key type preserve entries"},
43     {XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Unsupported modifier mask"},
44     {XKB_ERROR_EXPECTED_ARRAY_ENTRY, "Expected array entry"},
45     {XKB_WARNING_ILLEGAL_KEYCODE_ALIAS, "Illegal keycode alias"},
46     {XKB_WARNING_UNRECOGNIZED_KEYSYM, "Unrecognized keysym"},
47     {XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER, "Undeclared virtual modifier"},
48     {XKB_ERROR_WRONG_STATEMENT_TYPE, "Wrong statement type"},
49     {XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION, "Unsupported geometry section"},
50     {XKB_WARNING_CANNOT_INFER_KEY_TYPE, "Cannot infer key type"},
51     {XKB_WARNING_INVALID_ESCAPE_SEQUENCE, "Invalid escape sequence"},
52     {XKB_WARNING_ILLEGAL_KEY_TYPE_PRESERVE_RESULT, "Illegal key type preserve result"},
53     {XKB_ERROR_INVALID_INCLUDE_STATEMENT, "Invalid include statement"},
54     {XKB_ERROR_INVALID_MODMAP_ENTRY, "Invalid modmap entry"},
55     {XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Unsupported group index"},
56     {XKB_WARNING_CONFLICTING_KEY_TYPE_LEVEL_NAMES, "Conflicting key type level names"},
57     {XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT, "Invalid set default statement"},
58     {XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY, "Conflicting key type map entry"},
59     {XKB_WARNING_UNDEFINED_KEY_TYPE, "Undefined key type"},
60     {XKB_WARNING_NON_BASE_GROUP_NAME, "Non base group name"},
61     {XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL, "Unsupported shift level"},
62     {XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "Included file not found"},
63     {XKB_ERROR_UNKNOWN_OPERATOR, "Unknown operator"},
64     {XKB_WARNING_DUPLICATE_ENTRY, "Duplicate entry"},
65     {XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS, "Conflicting key type definitions"},
66     {XKB_ERROR_WRONG_SCOPE, "Wrong scope"},
67     {XKB_WARNING_MISSING_DEFAULT_SECTION, "Missing default section"},
68     {XKB_WARNING_CONFLICTING_KEY_SYMBOL, "Conflicting key symbol"},
69     {XKB_ERROR_INVALID_OPERATION, "Invalid operation"},
70     {XKB_WARNING_NUMERIC_KEYSYM, "Numeric keysym"},
71     {XKB_WARNING_EXTRA_SYMBOLS_IGNORED, "Extra symbols ignored"},
72     {XKB_WARNING_CONFLICTING_KEY_NAME, "Conflicting key name"},
73     {XKB_ERROR_ALLOCATION_ERROR, "Allocation error"},
74     {XKB_ERROR_WRONG_FIELD_TYPE, "Wrong field type"},
75     {XKB_ERROR_INVALID_REAL_MODIFIER, "Invalid real modifier"},
76     {XKB_WARNING_UNKNOWN_CHAR_ESCAPE_SEQUENCE, "Unknown char escape sequence"},
77     {XKB_ERROR_INVALID_INCLUDED_FILE, "Invalid included file"},
78     {XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE, "Multiple groups at once"},
79     {XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Unsupported symbols field"},
80     {XKB_ERROR_INVALID_SYNTAX, "Invalid syntax"},
81     {XKB_WARNING_UNDEFINED_KEYCODE, "Undefined keycode"},
82     {XKB_ERROR_INVALID_EXPRESSION_TYPE, "Invalid expression type"},
83     {XKB_ERROR_INVALID_VALUE, "Invalid value"},
84     {XKB_WARNING_CONFLICTING_MODMAP, "Conflicting modmap"},
85     {XKB_ERROR_UNKNOWN_FIELD, "Unknown field"},
86     {XKB_WARNING_CONFLICTING_KEY_ACTION, "Conflicting key action"},
87     {XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS, "Conflicting key type merging groups"},
88     {XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY, "Conflicting key symbols entry"},
89     {XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX, "Missing symbols group name index"},
90     {XKB_WARNING_CONFLICTING_KEY_FIELDS, "Conflicting key fields"},
91     {XKB_ERROR_INVALID_IDENTIFIER, "Invalid identifier"},
92     {XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL, "Unresolved keymap symbol"},
93     {XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE, "Undeclared modifiers in key type"}
94 };
95
96 int
97 xkb_message_get_all(const struct xkb_message_entry **messages)
98 {
99     *messages = xkb_messages;
100     return ARRAY_SIZE(xkb_messages);
101 }
102
103 const struct xkb_message_entry*
104 xkb_message_get(xkb_message_code_t code)
105 {
106     if (code < _XKB_LOG_MESSAGE_MIN_CODE || code > _XKB_LOG_MESSAGE_MAX_CODE)
107         return NULL;
108
109     for (size_t idx = 0; idx < ARRAY_SIZE(xkb_messages); idx++) {
110         if (xkb_messages[idx].code == code)
111             return &xkb_messages[idx];
112     }
113
114     /* no matching message code found */
115     return NULL;
116 }