mirror of
https://github.com/systemd/systemd.git
synced 2024-11-06 16:59:03 +03:00
libudev-util: add assertions
This commit is contained in:
parent
e3b8d0637d
commit
805a7097ee
@ -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 util_path_encode(const char *src, char *dest, size_t size) {
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
|
|
||||||
|
assert(src);
|
||||||
|
assert(dest);
|
||||||
|
|
||||||
for (i = 0, j = 0; src[i] != '\0'; i++) {
|
for (i = 0, j = 0; src[i] != '\0'; i++) {
|
||||||
if (src[i] == '/') {
|
if (src[i] == '/') {
|
||||||
if (j+4 >= size) {
|
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) {
|
int util_replace_whitespace(const char *str, char *to, size_t len) {
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
|
|
||||||
|
assert(str);
|
||||||
|
assert(to);
|
||||||
|
|
||||||
/* strip trailing whitespace */
|
/* strip trailing whitespace */
|
||||||
len = strnlen(str, len);
|
len = strnlen(str, len);
|
||||||
while (len && isspace(str[len-1]))
|
while (len && isspace(str[len-1]))
|
||||||
@ -158,6 +164,8 @@ int util_replace_chars(char *str, const char *white) {
|
|||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
int replaced = 0;
|
int replaced = 0;
|
||||||
|
|
||||||
|
assert(str);
|
||||||
|
|
||||||
while (str[i] != '\0') {
|
while (str[i] != '\0') {
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user