Skip to content

Commit

Permalink
logging: Added new error messages ID for keymap and rules
Browse files Browse the repository at this point in the history
  • Loading branch information
wismill committed Sep 25, 2024
1 parent 1b83771 commit a898bc8
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 19 deletions.
32 changes: 31 additions & 1 deletion doc/message-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NOTE: This file has been generated automatically by “update-message-registry.p
-->

This page lists the warnings and errors generated by xkbcommon.
There are currently 57 entries.
There are currently 60 entries.

@todo The documentation of the log messages is a work in progress.

Expand All @@ -23,6 +23,7 @@ There are currently 57 entries.
| [XKB-123] | `undeclared-virtual-modifier` | A virtual modifier is used before being declared | Error |
| [XKB-134] | `insufficient-buffer-size` | A buffer has an insufficient size | Error |
| [XKB-150] | `wrong-statement-type` | The type of the statement is not allowed in the context | Error |
| [XKB-161] | `invalid-path` | The given path is invalid | Error |
| [XKB-172] | `unsupported-geometry-section` | Geometry sections are not supported | Warning |
| [XKB-183] | `cannot-infer-key-type` | Warn if no key type can be inferred | Warning |
| [XKB-193] | `invalid-escape-sequence` | Invalid escape sequence in a string | Warning |
Expand Down Expand Up @@ -52,6 +53,7 @@ There are currently 57 entries.
| [XKB-523] | `conflicting-key-name` | Conflicting definitions of a key name or alias | Warning |
| [XKB-550] | `allocation-error` | Cannot allocate memory | Error |
| [XKB-578] | `wrong-field-type` | Warn when a field has not the expected type | Error |
| [XKB-595] | `cannot-resolve-rmlvo` | Cannot resolve a given (Rules, Model, Layout, Variant, Options) configuration | Error |
| [XKB-623] | `invalid-real-modifier` | Invalid _real_ modifier | Error |
| [XKB-645] | `unknown-char-escape-sequence` | Warn on unknown escape sequence in string literal | Warning |
| [XKB-661] | `invalid-included-file` | The target file of an include statement could not be processed | Error |
Expand All @@ -63,6 +65,7 @@ There are currently 57 entries.
| [XKB-796] | `invalid-value` | A value is invalid and will be ignored | Error |
| [XKB-800] | `conflicting-modmap` | Warn if there are conflicting modmap definitions | Warning |
| [XKB-812] | `unknown-field` | A field is unknown and will be ignored | Error |
| [XKB-822] | `keymap-compilation-failed` | Keymap compilation failed | Error |
| [XKB-883] | `conflicting-key-action` | Warn if there are conflicting actions while merging keys | Warning |
| [XKB-893] | `conflicting-key-type-merging-groups` | Warn if there are conflicting key types while merging groups | Warning |
| [XKB-901] | `conflicting-key-symbols-entry` | Conflicting symbols entry for a key | Error |
Expand Down Expand Up @@ -195,6 +198,14 @@ key <AB08> {[ comma, semicolon, periodcentered, multiply ]};
<dt>Summary</dt><dd>The type of the statement is not allowed in the context</dd>
</dl>

### XKB-161 – Invalid path {#XKB-161}

<dl>
<dt>Since</dt><dd>1.0.0</dd>
<dt>Type</dt><dd>Error</dd>
<dt>Summary</dt><dd>The given path is invalid</dd>
</dl>

### XKB-172 – Unsupported geometry section {#XKB-172}

<dl>
Expand Down Expand Up @@ -538,6 +549,14 @@ key <AE01> { [ U1ED0 ] };
<dt>Summary</dt><dd>Warn when a field has not the expected type</dd>
</dl>

### XKB-595 – Cannot resolve rmlvo {#XKB-595}

<dl>
<dt>Since</dt><dd>1.0.0</dd>
<dt>Type</dt><dd>Error</dd>
<dt>Summary</dt><dd>Cannot resolve a given (Rules, Model, Layout, Variant, Options) configuration</dd>
</dl>

### XKB-623 – Invalid real modifier {#XKB-623}

<dl>
Expand Down Expand Up @@ -644,6 +663,14 @@ xkbcommon support the following escape sequences in string literals:
<dt>Summary</dt><dd>A field is unknown and will be ignored</dd>
</dl>

### XKB-822 – Keymap compilation failed {#XKB-822}

<dl>
<dt>Since</dt><dd>1.0.0</dd>
<dt>Type</dt><dd>Error</dd>
<dt>Summary</dt><dd>Keymap compilation failed</dd>
</dl>

### XKB-883 – Conflicting key action {#XKB-883}

<dl>
Expand Down Expand Up @@ -721,6 +748,7 @@ The modifiers used in `map` or `preserve` entries should be declared using the e
[XKB-123]: @ref XKB-123
[XKB-134]: @ref XKB-134
[XKB-150]: @ref XKB-150
[XKB-161]: @ref XKB-161
[XKB-172]: @ref XKB-172
[XKB-183]: @ref XKB-183
[XKB-193]: @ref XKB-193
Expand Down Expand Up @@ -750,6 +778,7 @@ The modifiers used in `map` or `preserve` entries should be declared using the e
[XKB-523]: @ref XKB-523
[XKB-550]: @ref XKB-550
[XKB-578]: @ref XKB-578
[XKB-595]: @ref XKB-595
[XKB-623]: @ref XKB-623
[XKB-645]: @ref XKB-645
[XKB-661]: @ref XKB-661
Expand All @@ -761,6 +790,7 @@ The modifiers used in `map` or `preserve` entries should be declared using the e
[XKB-796]: @ref XKB-796
[XKB-800]: @ref XKB-800
[XKB-812]: @ref XKB-812
[XKB-822]: @ref XKB-822
[XKB-883]: @ref XKB-883
[XKB-893]: @ref XKB-893
[XKB-901]: @ref XKB-901
Expand Down
15 changes: 15 additions & 0 deletions doc/message-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@
added: ALWAYS
type: error
description: "The type of the statement is not allowed in the context"
- id: "invalid-path"
code: 161
added: ALWAYS
type: error
description: "The given path is invalid"
- id: "unsupported-geometry-section"
code: 172
added: ALWAYS
Expand Down Expand Up @@ -312,6 +317,11 @@
added: ALWAYS
type: error
description: "Warn when a field has not the expected type"
- id: "cannot-resolve-rmlvo"
code: 595
added: ALWAYS
type: error
description: "Cannot resolve a given (Rules, Model, Layout, Variant, Options) configuration"
- id: "invalid-real-modifier"
code: 623
added: ALWAYS
Expand Down Expand Up @@ -383,6 +393,11 @@
added: ALWAYS
type: error
description: "A field is unknown and will be ignored"
- id: "keymap-compilation-failed"
code: 822
added: ALWAYS
type: error
description: "Keymap compilation failed"
- id: "conflicting-key-action"
code: 883
added: ALWAYS
Expand Down
6 changes: 6 additions & 0 deletions src/messages-codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ enum xkb_message_code {
XKB_ERROR_INSUFFICIENT_BUFFER_SIZE = 134,
/** The type of the statement is not allowed in the context */
XKB_ERROR_WRONG_STATEMENT_TYPE = 150,
/** The given path is invalid */
XKB_ERROR_INVALID_PATH = 161,
/** Geometry sections are not supported */
XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION = 172,
/** Warn if no key type can be inferred */
Expand Down Expand Up @@ -121,6 +123,8 @@ enum xkb_message_code {
XKB_ERROR_ALLOCATION_ERROR = 550,
/** Warn when a field has not the expected type */
XKB_ERROR_WRONG_FIELD_TYPE = 578,
/** Cannot resolve a given (Rules, Model, Layout, Variant, Options) configuration */
XKB_ERROR_CANNOT_RESOLVE_RMLVO = 595,
/** Invalid _real_ modifier */
XKB_ERROR_INVALID_REAL_MODIFIER = 623,
/** Warn on unknown escape sequence in string literal */
Expand All @@ -143,6 +147,8 @@ enum xkb_message_code {
XKB_WARNING_CONFLICTING_MODMAP = 800,
/** A field is unknown and will be ignored */
XKB_ERROR_UNKNOWN_FIELD = 812,
/** Keymap compilation failed */
XKB_ERROR_KEYMAP_COMPILATION_FAILED = 822,
/** Warn if there are conflicting actions while merging keys */
XKB_WARNING_CONFLICTING_KEY_ACTION = 883,
/** Warn if there are conflicting key types while merging groups */
Expand Down
9 changes: 7 additions & 2 deletions src/registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,13 @@ rxkb_context_include_path_append(struct rxkb_context *ctx, const char *path)
* where this is the wrong behaviour aren't worth worrying about.
*/
if (!snprintf_safe(rules, sizeof(rules), "%s/rules/%s.xml",
path, DEFAULT_XKB_RULES))
path, DEFAULT_XKB_RULES)) {
log_err(ctx, XKB_ERROR_INVALID_PATH,
"Path is too long: expected max length of %zu, "
"got: %s/rules/%s.xml\n",
sizeof(rules), path, DEFAULT_XKB_RULES);
return false;
}

tmp = strdup(path);
if (!tmp)
Expand Down Expand Up @@ -1140,7 +1145,7 @@ xml_error_func(void *ctx, const char *msg, ...)

/* This shouldn't really happen */
if (rc < 0) {
log_err(ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(ctx, XKB_ERROR_INSUFFICIENT_BUFFER_SIZE,
"+++ out of cheese error. redo from start +++\n");
slen = 0;
memset(buf, 0, sizeof(buf));
Expand Down
9 changes: 5 additions & 4 deletions src/xkbcomp/include.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
if (!snprintf_safe(buf, sizeof(buf), "%s/%s/%s",
xkb_context_include_path_get(ctx, i),
typeDir, name)) {
log_err(ctx, XKB_ERROR_INSUFFICIENT_BUFFER_SIZE,
"Path is too long: expected max length of %lu, got: %s/%s/%s\n",
(unsigned long int) sizeof(buf),
xkb_context_include_path_get(ctx, i), typeDir, name);
log_err(ctx, XKB_ERROR_INVALID_PATH,
"Path is too long: expected max length of %zu, "
"got: %s/%s/%s\n",
sizeof(buf), xkb_context_include_path_get(ctx, i),
typeDir, name);
continue;
}

Expand Down
15 changes: 9 additions & 6 deletions src/xkbcomp/rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,11 @@ xkb_components_from_rules(struct xkb_context *ctx,
unsigned int offset = 0;

file = FindFileInXkbPath(ctx, rmlvo->rules, FILE_TYPE_RULES, &path, &offset);
if (!file)
if (!file) {
log_err(ctx, XKB_ERROR_CANNOT_RESOLVE_RMLVO,
"Cannot load XKB rules \"%s\"\n", rmlvo->rules);
goto err_out;
}

matcher = matcher_new(ctx, rmlvo);

Expand All @@ -1226,7 +1229,7 @@ xkb_components_from_rules(struct xkb_context *ctx,
darray_empty(matcher->kccgst[KCCGST_COMPAT]) ||
/* darray_empty(matcher->kccgst[KCCGST_GEOMETRY]) || */
darray_empty(matcher->kccgst[KCCGST_SYMBOLS])) {
log_err(ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(ctx, XKB_ERROR_CANNOT_RESOLVE_RMLVO,
"No components returned from XKB rules \"%s\"\n", path);
ret = false;
goto err_out;
Expand All @@ -1240,22 +1243,22 @@ xkb_components_from_rules(struct xkb_context *ctx,

mval = &matcher->rmlvo.model;
if (!mval->matched && mval->sval.len > 0)
log_err(matcher->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(matcher->ctx, XKB_ERROR_CANNOT_RESOLVE_RMLVO,
"Unrecognized RMLVO model \"%.*s\" was ignored\n",
mval->sval.len, mval->sval.start);
darray_foreach(mval, matcher->rmlvo.layouts)
if (!mval->matched && mval->sval.len > 0)
log_err(matcher->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(matcher->ctx, XKB_ERROR_CANNOT_RESOLVE_RMLVO,
"Unrecognized RMLVO layout \"%.*s\" was ignored\n",
mval->sval.len, mval->sval.start);
darray_foreach(mval, matcher->rmlvo.variants)
if (!mval->matched && mval->sval.len > 0)
log_err(matcher->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(matcher->ctx, XKB_ERROR_CANNOT_RESOLVE_RMLVO,
"Unrecognized RMLVO variant \"%.*s\" was ignored\n",
mval->sval.len, mval->sval.start);
darray_foreach(mval, matcher->rmlvo.options)
if (!mval->matched && mval->sval.len > 0)
log_err(matcher->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(matcher->ctx, XKB_ERROR_CANNOT_RESOLVE_RMLVO,
"Unrecognized RMLVO option \"%.*s\" was ignored\n",
mval->sval.len, mval->sval.start);

Expand Down
12 changes: 6 additions & 6 deletions src/xkbcomp/xkbcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ static bool
compile_keymap_file(struct xkb_keymap *keymap, XkbFile *file)
{
if (file->file_type != FILE_TYPE_KEYMAP) {
log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(keymap->ctx, XKB_ERROR_KEYMAP_COMPILATION_FAILED,
"Cannot compile a %s file alone into a keymap\n",
xkb_file_type_to_string(file->file_type));
return false;
}

if (!CompileKeymap(file, keymap, MERGE_OVERRIDE)) {
log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(keymap->ctx, XKB_ERROR_KEYMAP_COMPILATION_FAILED,
"Failed to compile keymap\n");
return false;
}
Expand All @@ -67,7 +67,7 @@ text_v1_keymap_new_from_names(struct xkb_keymap *keymap,

ok = xkb_components_from_rules(keymap->ctx, rmlvo, &kccgst);
if (!ok) {
log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(keymap->ctx, XKB_ERROR_KEYMAP_COMPILATION_FAILED,
"Couldn't look up rules '%s', model '%s', layout '%s', "
"variant '%s', options '%s'\n",
rmlvo->rules, rmlvo->model, rmlvo->layout, rmlvo->variant,
Expand All @@ -88,7 +88,7 @@ text_v1_keymap_new_from_names(struct xkb_keymap *keymap,
free(kccgst.symbols);

if (!file) {
log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(keymap->ctx, XKB_ERROR_KEYMAP_COMPILATION_FAILED,
"Failed to generate parsed XKB file from components\n");
return false;
}
Expand All @@ -107,7 +107,7 @@ text_v1_keymap_new_from_string(struct xkb_keymap *keymap,

xkb_file = XkbParseString(keymap->ctx, string, len, "(input string)", NULL);
if (!xkb_file) {
log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(keymap->ctx, XKB_ERROR_KEYMAP_COMPILATION_FAILED,
"Failed to parse input xkb string\n");
return false;
}
Expand All @@ -125,7 +125,7 @@ text_v1_keymap_new_from_file(struct xkb_keymap *keymap, FILE *file)

xkb_file = XkbParseFile(keymap->ctx, file, "(unknown file)", NULL);
if (!xkb_file) {
log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
log_err(keymap->ctx, XKB_ERROR_KEYMAP_COMPILATION_FAILED,
"Failed to parse input xkb file\n");
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions tools/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static const struct xkb_message_entry xkb_messages[] = {
{XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER, "Undeclared virtual modifier"},
{XKB_ERROR_INSUFFICIENT_BUFFER_SIZE, "Insufficient buffer size"},
{XKB_ERROR_WRONG_STATEMENT_TYPE, "Wrong statement type"},
{XKB_ERROR_INVALID_PATH, "Invalid path"},
{XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION, "Unsupported geometry section"},
{XKB_WARNING_CANNOT_INFER_KEY_TYPE, "Cannot infer key type"},
{XKB_WARNING_INVALID_ESCAPE_SEQUENCE, "Invalid escape sequence"},
Expand Down Expand Up @@ -76,6 +77,7 @@ static const struct xkb_message_entry xkb_messages[] = {
{XKB_WARNING_CONFLICTING_KEY_NAME, "Conflicting key name"},
{XKB_ERROR_ALLOCATION_ERROR, "Allocation error"},
{XKB_ERROR_WRONG_FIELD_TYPE, "Wrong field type"},
{XKB_ERROR_CANNOT_RESOLVE_RMLVO, "Cannot resolve rmlvo"},
{XKB_ERROR_INVALID_REAL_MODIFIER, "Invalid real modifier"},
{XKB_WARNING_UNKNOWN_CHAR_ESCAPE_SEQUENCE, "Unknown char escape sequence"},
{XKB_ERROR_INVALID_INCLUDED_FILE, "Invalid included file"},
Expand All @@ -87,6 +89,7 @@ static const struct xkb_message_entry xkb_messages[] = {
{XKB_ERROR_INVALID_VALUE, "Invalid value"},
{XKB_WARNING_CONFLICTING_MODMAP, "Conflicting modmap"},
{XKB_ERROR_UNKNOWN_FIELD, "Unknown field"},
{XKB_ERROR_KEYMAP_COMPILATION_FAILED, "Keymap compilation failed"},
{XKB_WARNING_CONFLICTING_KEY_ACTION, "Conflicting key action"},
{XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS, "Conflicting key type merging groups"},
{XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY, "Conflicting key symbols entry"},
Expand Down

0 comments on commit a898bc8

Please sign in to comment.