chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
0c1e4d7
)
sysctl: minor simplifications
author
Lennart Poettering
<lennart@poettering.net>
Fri, 24 Apr 2015 17:56:24 +0000
(19:56 +0200)
committer
Sven Eden
<yamakuzure@gmx.net>
Tue, 14 Mar 2017 07:13:59 +0000
(08:13 +0100)
src/shared/sysctl-util.c
patch
|
blob
|
history
diff --git
a/src/shared/sysctl-util.c
b/src/shared/sysctl-util.c
index 650c9c98b9bab0c81352e970da1255d1619e246c..55f4e48601436757d0bd7ed31ae062bb296bc5f9 100644
(file)
--- 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) {
}
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) {
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);
}
return read_full_file(p, content, NULL);
}