diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-21 16:32:54 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-21 16:32:54 +0900 |
commit | 805a7097eed1c5de0628c577c7c1dba90fac6511 (patch) | |
tree | 7da9fc815ca5e0c2e1e4a0a29cb437a33fdd4e2d /src/libudev/libudev-util.c | |
parent | e3b8d0637dd755b3426f3363b2cdad63f738116c (diff) | |
download | systemd-805a7097eed1c5de0628c577c7c1dba90fac6511.tar.gz |
libudev-util: add assertions
Diffstat (limited to 'src/libudev/libudev-util.c')
-rw-r--r-- | src/libudev/libudev-util.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libudev/libudev-util.c b/src/libudev/libudev-util.c index f07b29ab48..d6362cac0c 100644 --- a/src/libudev/libudev-util.c +++ b/src/libudev/libudev-util.c @@ -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; |