]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
string-table: drop unneeded initialization
authorMike Yuan <me@yhndnzj.com>
Tue, 27 May 2025 14:55:43 +0000 (16:55 +0200)
committerMike Yuan <me@yhndnzj.com>
Sat, 5 Jul 2025 20:26:23 +0000 (22:26 +0200)
src/basic/string-table.c

index fa3cc15743dcabe335c6d9b874e423f97987b785..069cb40ec1a0d571f1648cecfaa568874e6d7296 100644 (file)
@@ -42,6 +42,7 @@ int string_table_lookup_to_string_fallback(const char * const *table, size_t len
 
         if (i < 0 || i > (ssize_t) max)
                 return -ERANGE;
+
         if (i < (ssize_t) len && table[i]) {
                 s = strdup(table[i]);
                 if (!s)
@@ -54,14 +55,14 @@ int string_table_lookup_to_string_fallback(const char * const *table, size_t len
 }
 
 ssize_t string_table_lookup_from_string_fallback(const char * const *table, size_t len, const char *s, size_t max) {
-        unsigned u = 0;
-
         if (!s)
                 return -EINVAL;
 
         ssize_t i = string_table_lookup_from_string(table, len, s);
         if (i >= 0)
                 return i;
+
+        unsigned u;
         if (safe_atou(s, &u) < 0)
                 return -EINVAL;
         if (u > max)