From 842fabc3dcb86bc6863c4ae6c0b7a21fbb7e8ccc Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 5 Oct 2014 19:19:49 +0200 Subject: [PATCH] data: Ensure a stable ordering in cmp() in case of type-mismatches. So far, this doesn't make a difference but it's better style anyway. --- src/core/data.c | 2 +- src/include/core/data.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/data.c b/src/core/data.c index 968e99d..1188b40 100644 --- a/src/core/data.c +++ b/src/core/data.c @@ -293,7 +293,7 @@ sdb_data_cmp(const sdb_data_t *d1, const sdb_data_t *d2) CMP_NULL(d1, d2); if (d1->type != d2->type) - return -1; + return SDB_CMP(d1->type, d2->type); switch (d1->type) { case SDB_TYPE_INTEGER: diff --git a/src/include/core/data.h b/src/include/core/data.h index 6e4d317..02f99c5 100644 --- a/src/include/core/data.h +++ b/src/include/core/data.h @@ -105,7 +105,7 @@ sdb_data_free_datum(sdb_data_t *datum); /* * sdb_data_cmp: * Compare two data points. A NULL datum is considered less than any non-NULL - * datum. On data-type mismatch, the function always returns a negative value. + * datum. On data-type mismatch, the function always returns a non-zero value. * * Returns: * - a value less than zero if d1 compares less than d2 -- 2.30.2