From 78c7d0efae91cde1a992f69c1a0157b39e971670 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 7 May 2005 14:22:38 -0400 Subject: [PATCH] Clean up the debugging code in the blkid library so that we don't use the inline functions DEB_DUMP_* and instead use the private functions blkid_debug_dump_*(). --- lib/blkid/ChangeLog | 4 ++++ lib/blkid/blkidP.h | 61 ++--------------------------------------------------- lib/blkid/cache.c | 22 ++++++++++++++++++- lib/blkid/dev.c | 26 ++++++++++++++++++++++- lib/blkid/read.c | 2 +- lib/blkid/tag.c | 14 +++++++++++- 6 files changed, 66 insertions(+), 63 deletions(-) diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index f558da8..6bb62b2 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,5 +1,9 @@ 2005-05-07 Theodore Ts'o + * blkidP.h, cache.c, dev.c, read.c, tag.c: Clean up the debugging + code so that we don't use the inline functions DEB_DUMP_* + and instead use the private functions blkid_debug_dump_*(). + * tag.c (blkid_dev_has_tag): New function which returns 1 if a tag has a particular type and possibly value. diff --git a/lib/blkid/blkidP.h b/lib/blkid/blkidP.h index 1bb9490..e6d8e27 100644 --- a/lib/blkid/blkidP.h +++ b/lib/blkid/blkidP.h @@ -148,65 +148,8 @@ extern int blkid_debug_mask; #endif #ifdef CONFIG_BLKID_DEBUG -static inline void DEB_DUMP_TAG(int mask, blkid_tag tag) -{ - if (!(mask & blkid_debug_mask)) - return; - - if (!tag) { - printf(" tag: NULL\n"); - return; - } - - printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val); -} - -static inline void DEB_DUMP_DEV(int mask, blkid_dev dev) -{ - struct list_head *p; - - if (!(mask & blkid_debug_mask)) - return; - - if (!dev) { - printf(" dev: NULL\n"); - return; - } - - printf(" dev: name = %s\n", dev->bid_name); - printf(" dev: DEVNO=\"0x%0Lx\"\n", dev->bid_devno); - printf(" dev: TIME=\"%lu\"\n", dev->bid_time); - printf(" dev: PRI=\"%d\"\n", dev->bid_pri); - printf(" dev: flags = 0x%08X\n", dev->bid_flags); - - list_for_each(p, &dev->bid_tags) { - blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags); - DEB_DUMP_TAG(mask, tag); - } - printf("\n"); -} - -static inline void DEB_DUMP_CACHE(int mask, blkid_cache cache) -{ - struct list_head *p; - - if (!cache || !(mask & blkid_debug_mask)) { - printf("cache: NULL\n"); - return; - } - - printf("cache: time = %lu\n", cache->bic_time); - printf("cache: flags = 0x%08X\n", cache->bic_flags); - - list_for_each(p, &cache->bic_devs) { - blkid_dev dev = list_entry(p, struct blkid_struct_dev, bid_devs); - DEB_DUMP_DEV(mask, dev); - } -} -#else -#define DEB_DUMP_TAG(mask, tag) do {} while (0) -#define DEB_DUMP_DEV(mask, dev) do {} while (0) -#define DEB_DUMP_CACHE(mask, cache) do {} while (0) +extern void blkid_debug_dump_dev(blkid_dev dev); +extern void blkid_debug_dump_tag(blkid_tag tag); #endif /* lseek.c */ diff --git a/lib/blkid/cache.c b/lib/blkid/cache.c index 0ecaa2d..497b0fe 100644 --- a/lib/blkid/cache.c +++ b/lib/blkid/cache.c @@ -52,6 +52,26 @@ static char *safe_getenv(const char *arg) #endif } +#if 0 /* ifdef CONFIG_BLKID_DEBUG */ +static blkid_debug_dump_cache(int mask, blkid_cache cache) +{ + struct list_head *p; + + if (!cache) { + printf("cache: NULL\n"); + return; + } + + printf("cache: time = %lu\n", cache->bic_time); + printf("cache: flags = 0x%08X\n", cache->bic_flags); + + list_for_each(p, &cache->bic_devs) { + blkid_dev dev = list_entry(p, struct blkid_struct_dev, bid_devs); + blkid_debug_dump_dev(dev); + } +} +#endif + int blkid_get_cache(blkid_cache *ret_cache, const char *filename) { blkid_cache cache; @@ -98,7 +118,7 @@ void blkid_put_cache(blkid_cache cache) DBG(DEBUG_CACHE, printf("freeing cache struct\n")); - /* DEB_DUMP_CACHE(cache); */ + /* DBG(DEBUG_CACHE, blkid_debug_dump_cache(cache)); */ while (!list_empty(&cache->bic_devs)) { blkid_dev dev = list_entry(cache->bic_devs.next, diff --git a/lib/blkid/dev.c b/lib/blkid/dev.c index 081bedf..3ac3195 100644 --- a/lib/blkid/dev.c +++ b/lib/blkid/dev.c @@ -35,7 +35,7 @@ void blkid_free_dev(blkid_dev dev) DBG(DEBUG_DEV, printf(" freeing dev %s (%s)\n", dev->bid_name, dev->bid_type)); - DEB_DUMP_DEV(DEBUG_DEV, dev); + DBG(DEBUG_DEV, blkid_debug_dump_dev(dev)); list_del(&dev->bid_devs); while (!list_empty(&dev->bid_tags)) { @@ -57,6 +57,30 @@ extern const char *blkid_dev_devname(blkid_dev dev) return dev->bid_name; } +#ifdef CONFIG_BLKID_DEBUG +void blkid_debug_dump_dev(blkid_dev dev) +{ + struct list_head *p; + + if (!dev) { + printf(" dev: NULL\n"); + return; + } + + printf(" dev: name = %s\n", dev->bid_name); + printf(" dev: DEVNO=\"0x%0Lx\"\n", dev->bid_devno); + printf(" dev: TIME=\"%lu\"\n", dev->bid_time); + printf(" dev: PRI=\"%d\"\n", dev->bid_pri); + printf(" dev: flags = 0x%08X\n", dev->bid_flags); + + list_for_each(p, &dev->bid_tags) { + blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags); + blkid_debug_dump_tag(tag); + } + printf("\n"); +} +#endif + /* * dev iteration routines for the public libblkid interface. * diff --git a/lib/blkid/read.c b/lib/blkid/read.c index 358554c..7ea8e84 100644 --- a/lib/blkid/read.c +++ b/lib/blkid/read.c @@ -359,7 +359,7 @@ static int blkid_parse_line(blkid_cache cache, blkid_dev *dev_p, char *cp) blkid_free_dev(dev); } - DEB_DUMP_DEV(DEBUG_READ, dev); + DBG(DEBUG_READ, blkid_debug_dump_dev(dev)); return ret; } diff --git a/lib/blkid/tag.c b/lib/blkid/tag.c index e3df150..9470ac0 100644 --- a/lib/blkid/tag.c +++ b/lib/blkid/tag.c @@ -29,6 +29,18 @@ static blkid_tag blkid_new_tag(void) return tag; } +#ifdef CONFIG_BLKID_DEBUG +void blkid_debug_dump_tag(blkid_tag tag) +{ + if (!tag) { + printf(" tag: NULL\n"); + return; + } + + printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val); +} +#endif + void blkid_free_tag(blkid_tag tag) { if (!tag) @@ -36,7 +48,7 @@ void blkid_free_tag(blkid_tag tag) DBG(DEBUG_TAG, printf(" freeing tag %s=%s\n", tag->bit_name, tag->bit_val ? tag->bit_val : "(NULL)")); - DEB_DUMP_TAG(DEBUG_TAG, tag); + DBG(DEBUG_TAG, blkid_debug_dump_tag(tag)); list_del(&tag->bit_tags); /* list of tags for this device */ list_del(&tag->bit_names); /* list of tags with this type */ -- 1.8.3.1