]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: improve debug messages
authorKarel Zak <kzak@redhat.com>
Wed, 25 May 2016 13:06:22 +0000 (15:06 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 25 May 2016 13:06:22 +0000 (15:06 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/blkidP.h
libblkid/src/cache.c
libblkid/src/dev.c
libblkid/src/read.c
libblkid/src/tag.c

index e9a267e62bf278930136c88d7244340573b60c93..e298b41dd137163778a83dda1bcdb25ebf4835d7 100644 (file)
@@ -326,7 +326,6 @@ UL_DEBUG_DECLARE_MASK(libblkid);
 #define ON_DBG(m, x)    __UL_DBG_CALL(libblkid, BLKID_DEBUG_, m, x)
 
 extern void blkid_debug_dump_dev(blkid_dev dev);
-extern void blkid_debug_dump_tag(blkid_tag tag);
 
 
 /* devno.c */
index c6d02a48bb3706cb8e3607376deb9b5fa2bc7df3..fd0257cd79b362f01391c261866b9f1ac8603479 100644 (file)
@@ -99,12 +99,10 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename)
 
        blkid_init_debug(0);
 
-       DBG(CACHE, ul_debug("creating blkid cache (using %s)",
-                               filename ? filename : "default cache"));
-
        if (!(cache = calloc(1, sizeof(struct blkid_struct_cache))))
                return -BLKID_ERR_MEM;
 
+       DBG(CACHE, ul_debugobj(cache, "alloc (from %s)", filename ? filename : "default cache"));
        INIT_LIST_HEAD(&cache->bic_devs);
        INIT_LIST_HEAD(&cache->bic_tags);
 
@@ -133,7 +131,7 @@ void blkid_put_cache(blkid_cache cache)
 
        (void) blkid_flush_cache(cache);
 
-       DBG(CACHE, ul_debug("freeing cache struct"));
+       DBG(CACHE, ul_debugobj(cache, "freeing cache struct"));
 
        /* DBG(CACHE, ul_debug_dump_cache(cache)); */
 
@@ -144,6 +142,7 @@ void blkid_put_cache(blkid_cache cache)
                blkid_free_dev(dev);
        }
 
+       DBG(CACHE, ul_debugobj(cache, "freeing cache tag heads"));
        while (!list_empty(&cache->bic_tags)) {
                blkid_tag tag = list_entry(cache->bic_tags.next,
                                           struct blkid_struct_tag,
@@ -154,7 +153,7 @@ void blkid_put_cache(blkid_cache cache)
                                                   struct blkid_struct_tag,
                                                   bit_names);
 
-                       DBG(CACHE, ul_debug("warning: unfreed tag %s=%s",
+                       DBG(CACHE, ul_debugobj(cache, "warning: unfreed tag %s=%s",
                                                bad->bit_name, bad->bit_val));
                        blkid_free_tag(bad);
                }
@@ -184,7 +183,7 @@ void blkid_gc_cache(blkid_cache cache)
        list_for_each_safe(p, pnext, &cache->bic_devs) {
                blkid_dev dev = list_entry(p, struct blkid_struct_dev, bid_devs);
                if (stat(dev->bid_name, &st) < 0) {
-                       DBG(CACHE, ul_debug("freeing %s", dev->bid_name));
+                       DBG(CACHE, ul_debugobj(cache, "freeing non-exiting %s", dev->bid_name));
                        blkid_free_dev(dev);
                        cache->bic_flags |= BLKID_BIC_FL_CHANGED;
                } else {
index 8e5516bce6c368212bc91bde4033a54d28edb217..f35895da9862bb92327df8b12eb981237e4d9915 100644 (file)
@@ -37,6 +37,7 @@ blkid_dev blkid_new_dev(void)
        if (!(dev = calloc(1, sizeof(struct blkid_struct_dev))))
                return NULL;
 
+       DBG(DEV, ul_debugobj(dev, "alloc"));
        INIT_LIST_HEAD(&dev->bid_devs);
        INIT_LIST_HEAD(&dev->bid_tags);
 
@@ -48,10 +49,7 @@ void blkid_free_dev(blkid_dev dev)
        if (!dev)
                return;
 
-       DBG(DEV,
-           ul_debug("  freeing dev %s (%s)", dev->bid_name, dev->bid_type ?
-                  dev->bid_type : "(null)"));
-       DBG(DEV, blkid_debug_dump_dev(dev));
+       DBG(DEV, ul_debugobj(dev, "freeing (%s)", dev->bid_name));
 
        list_del(&dev->bid_devs);
        while (!list_empty(&dev->bid_tags)) {
index 41e564f4e31e416e3128b755534488def7d6742d..b7afe2cd2e6a9d4273c09a1d2a5f5a4eb1192a99 100644 (file)
@@ -321,6 +321,8 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp)
            (ret = parse_xml(&name, &value, cp)) <= 0 */)
                return ret;
 
+       DBG(READ, ul_debug("tag: %s=\"%s\"", name, value));
+
        /* Some tags are stored directly in the device struct */
        if (!strcmp(name, "DEVNO"))
                dev->bid_devno = strtoull(value, 0, 0);
@@ -334,8 +336,6 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp)
        } else
                ret = blkid_set_tag(dev, name, value, strlen(value));
 
-       DBG(READ, ul_debug("    tag: %s=\"%s\"", name, value));
-
        return ret < 0 ? ret : 1;
 }
 
@@ -377,7 +377,7 @@ static int blkid_parse_line(blkid_cache cache, blkid_dev *dev_p, char *cp)
                goto done;
        }
 
-       DBG(READ, blkid_debug_dump_dev(dev));
+       /*DBG(READ, blkid_debug_dump_dev(dev));*/
 
 done:
        return ret;
index 4dc7da139391a8eb44c40bd409f8927239017959..40cac016670b9d0d4921be4941de5db227d4151c 100644 (file)
@@ -24,30 +24,19 @@ static blkid_tag blkid_new_tag(void)
        if (!(tag = calloc(1, sizeof(struct blkid_struct_tag))))
                return NULL;
 
+       DBG(TAG, ul_debugobj(tag, "alloc"));
        INIT_LIST_HEAD(&tag->bit_tags);
        INIT_LIST_HEAD(&tag->bit_names);
 
        return tag;
 }
 
-void blkid_debug_dump_tag(blkid_tag tag)
-{
-       if (!tag) {
-               fprintf(stderr, "    tag: NULL\n");
-               return;
-       }
-
-       fprintf(stderr, "    tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val);
-}
-
 void blkid_free_tag(blkid_tag tag)
 {
        if (!tag)
                return;
 
-       DBG(TAG, ul_debug("    freeing tag %s=%s", tag->bit_name,
-                  tag->bit_val ? tag->bit_val : "(NULL)"));
-       DBG(TAG, blkid_debug_dump_tag(tag));
+       DBG(TAG, ul_debugobj(tag, "freeing tag %s (%s)", tag->bit_name, tag->bit_val));
 
        list_del(&tag->bit_tags);       /* list of tags for this device */
        list_del(&tag->bit_names);      /* list of tags with this type */
@@ -107,7 +96,7 @@ static blkid_tag blkid_find_head_cache(blkid_cache cache, const char *type)
        list_for_each(p, &cache->bic_tags) {
                tmp = list_entry(p, struct blkid_struct_tag, bit_tags);
                if (!strcmp(tmp->bit_name, type)) {
-                       DBG(TAG, ul_debug("    found cache tag head %s", type));
+                       DBG(TAG, ul_debug("found cache tag head %s", type));
                        head = tmp;
                        break;
                }
@@ -155,6 +144,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
                        free(val);
                        return 0;
                }
+               DBG(TAG, ul_debugobj(t, "update (%s) '%s' -> '%s'", t->bit_name, t->bit_val, val));
                free(t->bit_val);
                t->bit_val = val;
        } else {
@@ -165,6 +155,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
                t->bit_val = val;
                t->bit_dev = dev;
 
+               DBG(TAG, ul_debugobj(t, "setting (%s) '%s'", t->bit_name, t->bit_val));
                list_add_tail(&t->bit_tags, &dev->bid_tags);
 
                if (dev->bid_cache) {
@@ -175,7 +166,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
                                if (!head)
                                        goto errout;
 
-                               DBG(TAG, ul_debug("    creating new cache tag head %s", name));
+                               DBG(TAG, ul_debugobj(head, "creating new cache tag head %s", name));
                                head->bit_name = strdup(name);
                                if (!head->bit_name)
                                        goto errout;