diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-24 19:56:24 +0200 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2015-05-04 14:10:42 -0400 |
commit | f23824164480857fd39581e80dc75a1f852e38a6 (patch) | |
tree | 8a0f7909c0e60a14b7c5f8cadaf575617083b21d | |
parent | 7da901811ab1fb6b29fcfb9e4f590ff0c700a7c4 (diff) |
sysctl: minor simplifications
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
-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 87c3389e2e..5512cc9da5 100644 --- a/src/shared/sysctl-util.c +++ b/src/shared/sysctl-util.c @@ -57,31 +57,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); } |