summaryrefslogtreecommitdiffstats
path: root/src/fundamental/string-util-fundamental.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-05-17 14:19:19 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-05-17 16:33:43 +0200
commitdbf43adce2863e4362d6fa286bf77fd2dc47cdc1 (patch)
treea8346480332bda613321dd72a0987c8b48e43650 /src/fundamental/string-util-fundamental.c
parentfundamental/string-util-fundamental: include appropriate headers (diff)
downloadsystemd-dbf43adce2863e4362d6fa286bf77fd2dc47cdc1.tar.xz
systemd-dbf43adce2863e4362d6fa286bf77fd2dc47cdc1.zip
fundamental: make strverscmp_improved() return -1/0/+1 in all cases
We would return the result of strcmp(), i.e. some positive/negative value. Now that we want to make this a documented interface for other people to implement, let's make the implementation more contstrained, even if we ourselves don't care about whether the specific values.
Diffstat (limited to 'src/fundamental/string-util-fundamental.c')
-rw-r--r--src/fundamental/string-util-fundamental.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/fundamental/string-util-fundamental.c b/src/fundamental/string-util-fundamental.c
index 0d8a820bac..57b4d535f3 100644
--- a/src/fundamental/string-util-fundamental.c
+++ b/src/fundamental/string-util-fundamental.c
@@ -126,7 +126,7 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) {
*/
if (isempty(a) || isempty(b))
- return strcmp_ptr(a, b);
+ return CMP(strcmp_ptr(a, b), 0);
for (;;) {
const sd_char *aa, *bb;
@@ -208,7 +208,7 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) {
return r;
/* Then, compare them as strings. */
- r = strncmp(a, b, aa - a);
+ r = CMP(strncmp(a, b, aa - a), 0);
if (r != 0)
return r;
} else {
@@ -219,7 +219,7 @@ sd_int strverscmp_improved(const sd_char *a, const sd_char *b) {
;
/* Note that the segments are usually not NUL-terminated. */
- r = strncmp(a, b, MIN(aa - a, bb - b));
+ r = CMP(strncmp(a, b, MIN(aa - a, bb - b)), 0);
if (r != 0)
return r;