diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-24 19:56:24 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-03-14 08:13:59 +0100 |
commit | fbf626c7267dff7a824f2c7af389c94c2535b397 (patch) | |
tree | c09404e735545b1c356ab4b8e2d06474fc81b1ee /src | |
parent | 0c1e4d7c72cf2752d54f22e980a854adff514325 (diff) |
sysctl: minor simplifications
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/sysctl-util.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/shared/sysctl-util.c b/src/shared/sysctl-util.c index 650c9c98b..55f4e4860 100644 --- a/src/shared/sysctl-util.c +++ b/src/shared/sysctl-util.c @@ -58,31 +58,23 @@ char *sysctl_normalize(char *s) { } int sysctl_write(const char *property, const char *value) { - _cleanup_free_ char *p = NULL; - char *n; - - log_debug("Setting '%s' to '%s'", property, value); + char *p; - p = new(char, strlen("/proc/sys/") + strlen(property) + 1); - if (!p) - return log_oom(); + assert(property); + assert(value); - n = stpcpy(p, "/proc/sys/"); - strcpy(n, property); + log_debug("Setting '%s' to '%s'", property, value); + p = strjoina("/proc/sys/", property); return write_string_file(p, value); } int sysctl_read(const char *property, char **content) { - _cleanup_free_ char *p = NULL; - char *n; - - p = new(char, strlen("/proc/sys/") + strlen(property) + 1); - if (!p) - return log_oom(); + char *p; - n = stpcpy(p, "/proc/sys/"); - strcpy(n, property); + assert(property); + assert(content); + p = strjoina("/proc/sys/", property); return read_full_file(p, content, NULL); } |