networkd: minor refactoring

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2021-07-09 11:11:25 +02:00
parent 7dc7ab311b
commit ae732f6e2d
+6 -9
View File
@@ -110,6 +110,7 @@ int manager_get_route_table_from_string(const Manager *m, const char *s, uint32_
int manager_get_route_table_to_string(const Manager *m, uint32_t table, char **ret) {
_cleanup_free_ char *str = NULL;
const char *s;
int r;
assert(m);
assert(ret);
@@ -121,17 +122,13 @@ int manager_get_route_table_to_string(const Manager *m, uint32_t table, char **r
if (!s)
s = hashmap_get(m->route_table_names_by_number, UINT32_TO_PTR(table));
if (s) {
if (s)
/* Currently, this is only used in debugging logs. To not confuse any bug
* reports, let's include the table number. */
if (asprintf(&str, "%s(%" PRIu32 ")", s, table) < 0)
return -ENOMEM;
*ret = TAKE_PTR(str);
return 0;
}
if (asprintf(&str, "%" PRIu32, table) < 0)
r = asprintf(&str, "%s(%" PRIu32 ")", s, table);
else
r = asprintf(&str, "%" PRIu32, table);
if (r < 0)
return -ENOMEM;
*ret = TAKE_PTR(str);