atom: remove handling of garbage input Signed-off-by: Ran Benita <ran@unusedvar.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
diff --git a/src/atom.c b/src/atom.c
index 2ef7c85..aa6cfb3 100644
--- a/src/atom.c
+++ b/src/atom.c
@@ -117,9 +117,7 @@ atom_table_free(struct atom_table *table)
const char *
atom_text(struct atom_table *table, xkb_atom_t atom)
{
- if (atom == XKB_ATOM_NONE || atom >= darray_size(table->table))
- return NULL;
-
+ assert(atom < darray_size(table->table));
return darray_item(table->table, atom).string;
}
@@ -173,9 +171,6 @@ atom_lookup(struct atom_table *table, const char *string, size_t len)
{
xkb_atom_t *atomp;
- if (!string)
- return XKB_ATOM_NONE;
-
if (!find_atom_pointer(table, string, len, &atomp, NULL))
return XKB_ATOM_NONE;
@@ -189,16 +184,12 @@ atom_intern(struct atom_table *table, const char *string, size_t len)
struct atom_node node;
uint32_t fingerprint;
- if (!string)
- return XKB_ATOM_NONE;
-
if (find_atom_pointer(table, string, len, &atomp, &fingerprint)) {
return *atomp;
}
node.string = strndup(string, len);
- if (!node.string)
- return XKB_ATOM_NONE;
+ assert(node.string != NULL);
node.left = node.right = XKB_ATOM_NONE;
node.fingerprint = fingerprint;