}
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);
- return write_string_file(p, value);
+ p = strjoina("/proc/sys/", property);
+ return write_string_file(p, value, 0);
}
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);
}