1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 08:26:52 +03:00

libudev-util: add assertions

This commit is contained in:
Yu Watanabe 2018-11-21 16:32:54 +09:00
parent e3b8d0637d
commit 805a7097ee

View File

@ -84,6 +84,9 @@ int util_resolve_subsys_kernel(const char *string,
size_t util_path_encode(const char *src, char *dest, size_t size) {
size_t i, j;
assert(src);
assert(dest);
for (i = 0, j = 0; src[i] != '\0'; i++) {
if (src[i] == '/') {
if (j+4 >= size) {
@ -129,6 +132,9 @@ size_t util_path_encode(const char *src, char *dest, size_t size) {
int util_replace_whitespace(const char *str, char *to, size_t len) {
size_t i, j;
assert(str);
assert(to);
/* strip trailing whitespace */
len = strnlen(str, len);
while (len && isspace(str[len-1]))
@ -158,6 +164,8 @@ int util_replace_chars(char *str, const char *white) {
size_t i = 0;
int replaced = 0;
assert(str);
while (str[i] != '\0') {
int len;