networkd: minor refactoring
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user