mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-26 10:03:40 +03:00
make namespace_flags_to_string() not return empty string
This improves the following debug log. Before: systemd[1162]: Restricting namespace to: . After: systemd[1162]: Restricting namespace to: n/a.
This commit is contained in:
parent
fbd6ac2601
commit
dd0395b565
@ -127,7 +127,8 @@ int bus_property_get_triggered_unit(sd_bus *bus, const char *path, const char *i
|
||||
if (!UNIT_WRITE_FLAGS_NOOP(flags)) { \
|
||||
*p = (cast_type) v; \
|
||||
unit_write_settingf(u, flags, name, \
|
||||
"%s=%s", name, s); \
|
||||
"%s=%s", \
|
||||
name, strempty(s)); \
|
||||
} \
|
||||
\
|
||||
return 1; \
|
||||
|
@ -4881,7 +4881,7 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
|
||||
r = namespace_flags_to_string(c->restrict_namespaces, &s);
|
||||
if (r >= 0)
|
||||
fprintf(f, "%sRestrictNamespaces: %s\n",
|
||||
prefix, s);
|
||||
prefix, strna(s));
|
||||
}
|
||||
|
||||
if (c->network_namespace_path)
|
||||
|
@ -406,7 +406,7 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
result = s;
|
||||
result = strempty(s);
|
||||
}
|
||||
|
||||
bus_print_property_value(name, expected_value, value, result);
|
||||
|
@ -65,12 +65,6 @@ int namespace_flags_to_string(unsigned long flags, char **ret) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
s = strdup("");
|
||||
if (!s)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(s);
|
||||
|
||||
return 0;
|
||||
|
@ -190,7 +190,7 @@ static void test_restrict_namespace(void) {
|
||||
|
||||
log_info("/* %s */", __func__);
|
||||
|
||||
assert_se(namespace_flags_to_string(0, &s) == 0 && streq(s, ""));
|
||||
assert_se(namespace_flags_to_string(0, &s) == 0 && isempty(s));
|
||||
s = mfree(s);
|
||||
assert_se(namespace_flags_to_string(CLONE_NEWNS, &s) == 0 && streq(s, "mnt"));
|
||||
s = mfree(s);
|
||||
|
Loading…
x
Reference in New Issue
Block a user