summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-06-12 17:17:20 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-06-17 17:26:15 +0200
commit7b12b86450e684bec37c3c9c822b6101621c16b9 (patch)
tree01124e4851c350280facaff943d8354f899af561 /src
parentlogind: tweaklets (diff)
downloadsystemd-7b12b86450e684bec37c3c9c822b6101621c16b9.tar.xz
systemd-7b12b86450e684bec37c3c9c822b6101621c16b9.zip
strbuf: use CMP() macro
strbuf_child_entry.c is uint8_t, so using CMP() is safer. This also adds missing assertions.
Diffstat (limited to 'src')
-rw-r--r--src/basic/strbuf.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/basic/strbuf.c b/src/basic/strbuf.c
index 226893842b..c08aa82e54 100644
--- a/src/basic/strbuf.c
+++ b/src/basic/strbuf.c
@@ -74,9 +74,11 @@ struct strbuf* strbuf_free(struct strbuf *str) {
return mfree(str);
}
-static int strbuf_children_cmp(const struct strbuf_child_entry *n1,
- const struct strbuf_child_entry *n2) {
- return n1->c - n2->c;
+static int strbuf_children_cmp(const struct strbuf_child_entry *n1, const struct strbuf_child_entry *n2) {
+ assert(n1);
+ assert(n2);
+
+ return CMP(n1->c, n2->c);
}
static void bubbleinsert(struct strbuf_node *node,