sysctl: minor simplifications

This commit is contained in:
Lennart Poettering
2015-04-24 19:56:47 +02:00
parent e50b33bebd
commit 0f5a8be5fe
+9 -17
View File
@@ -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;
char *p;
assert(property);
assert(value);
log_debug("Setting '%s' to '%s'", property, value);
p = new(char, strlen("/proc/sys/") + strlen(property) + 1);
if (!p)
return log_oom();
n = stpcpy(p, "/proc/sys/");
strcpy(n, property);
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;
char *p;
p = new(char, strlen("/proc/sys/") + strlen(property) + 1);
if (!p)
return log_oom();
n = stpcpy(p, "/proc/sys/");
strcpy(n, property);
assert(property);
assert(content);
p = strjoina("/proc/sys/", property);
return read_full_file(p, content, NULL);
}