From: Christian Grothoff Date: Thu, 5 Jul 2012 07:57:40 +0000 (+0000) Subject: LRN: More logging for namespace comparison: X-Git-Tag: initial-import-from-subversion-38251~12646 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=60327189b5bcededb1c800415c1972d66d81366f;p=oweals%2Fgnunet.git LRN: More logging for namespace comparison: Changes GNUNET_NAMESTORE_records_cmp from a simple if statement to a chain of if statements, each of which will log the reason comparison failed before returning FALSE, making it obvious why comparison failed. --- diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c index eead6e492..d67628767 100644 --- a/src/namestore/namestore_common.c +++ b/src/namestore/namestore_common.c @@ -170,14 +170,44 @@ int GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, const struct GNUNET_NAMESTORE_RecordData *b) { - if ((a->record_type == b->record_type) && - (a->expiration_time == b->expiration_time) && - ((a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) - == (b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) ) && - (a->data_size == b->data_size) && - (0 == memcmp (a->data, b->data, a->data_size))) - return GNUNET_YES; - return GNUNET_NO; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Comparing records\n"); + if (a->record_type != b->record_type) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Record type %lu != %lu\n", a->record_type, b->record_type); + return GNUNET_NO; + } + if (a->expiration_time != b->expiration_time) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Expiration time %llu != %llu\n", a->expiration_time, b->expiration_time); + return GNUNET_NO; + } + if ((a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) + != (b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Flags %lu (%lu) != %lu (%lu)\n", a->flags, + a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS, b->flags, + b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS); + return GNUNET_NO; + } + if (a->data_size != b->data_size) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Data size %lu != %lu\n", a->data_size, b->data_size); + return GNUNET_NO; + } + if (0 != memcmp (a->data, b->data, a->data_size)) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Data contents do not match\n"); + return GNUNET_NO; + } + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Records are equal\n"); + return GNUNET_YES; }