summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-24 19:56:24 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-24 19:56:47 +0200
commit0f5a8be5fe6feb56fa306a793be7230fa630b93c (patch)
treea57548509b74c7853bbf96ae8222bdfa581acbc8 /src
parente50b33bebdfd9ab38f037fbdb38445c64d3aae98 (diff)
sysctl: minor simplifications
Diffstat (limited to 'src')
-rw-r--r--src/shared/sysctl-util.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/shared/sysctl-util.c b/src/shared/sysctl-util.c
index 650c9c98b9..55f4e48601 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);
}