From: Sebastian Harl Date: Sun, 5 Oct 2014 17:19:49 +0000 (+0200) Subject: data: Ensure a stable ordering in cmp() in case of type-mismatches. X-Git-Tag: sysdb-0.5.0~13 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=842fabc3dcb86bc6863c4ae6c0b7a21fbb7e8ccc;p=sysdb.git 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. --- 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