mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
We'd return -1 (-EPERM), even though we have a general rule to use real errno values. The particular case that caught my attention was: $ sudo udevadm control -l asdf Failed to parse log priority 'asdf': Operation not permitted ... but "git grep 'r =.*_from_string' src/" return 110 hits. Confusingly, some of the _from_string functions already return a proper errno value, so not all of those are broken, but probably quite a few.
16 lines
397 B
C
16 lines
397 B
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
|
|
#include "string-table.h"
|
|
#include "string-util.h"
|
|
|
|
ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
|
|
if (!key)
|
|
return -EINVAL;
|
|
|
|
for (size_t i = 0; i < len; ++i)
|
|
if (streq_ptr(table[i], key))
|
|
return (ssize_t) i;
|
|
|
|
return -EINVAL;
|
|
}
|