]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
strbuf: use CMP() macro
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 12 Jun 2024 15:17:20 +0000 (00:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 17 Jun 2024 15:26:15 +0000 (00:26 +0900)
strbuf_child_entry.c is uint8_t, so using CMP() is safer.

This also adds missing assertions.

src/basic/strbuf.c

index 226893842bbf8c4e171cb8c57467b2291f133cda..c08aa82e54f2257ff6dcd88f9bad490023cb9ca3 100644 (file)
@@ -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,