diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-09 13:27:03 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-09 15:07:40 +0200 |
commit | e437538f35e09f8caa3de6ca905da1f134aef5bb (patch) | |
tree | 9e642f08bf6f38af098dfab336d5e717d599ffdc /src/shared/udev-util.c | |
parent | basic/escape: use _cleanup_ in one more place (diff) | |
download | systemd-e437538f35e09f8caa3de6ca905da1f134aef5bb.tar.xz systemd-e437538f35e09f8caa3de6ca905da1f134aef5bb.zip |
tree-wide: make cunescape*() functions return ssize_t
Strictly speaking, we are returning the size of a memory chunk of
arbitrary size, so ssize_t is more appropriate than int.
Diffstat (limited to 'src/shared/udev-util.c')
-rw-r--r-- | src/shared/udev-util.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index f934fc157e..27dfd11a6a 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -351,7 +351,6 @@ void log_device_uevent(sd_device *device, const char *str) { int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos) { char *i, *j; - int r; bool is_escaped; /* value must be double quotated */ @@ -373,6 +372,7 @@ int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos) { j[0] = '\0'; } else { _cleanup_free_ char *unescaped = NULL; + ssize_t l; /* find the end position of value */ for (i = str; *i != '"'; i++) { @@ -383,11 +383,12 @@ int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos) { } i[0] = '\0'; - r = cunescape_length(str, i - str, 0, &unescaped); - if (r < 0) - return r; - assert(r <= i - str); - memcpy(str, unescaped, r + 1); + l = cunescape_length(str, i - str, 0, &unescaped); + if (l < 0) + return l; + + assert(l <= i - str); + memcpy(str, unescaped, l + 1); } *ret_value = str; |