]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: remove unnecessary position check from list_for_each_safe loops
authorKarel Zak <kzak@redhat.com>
Mon, 12 Sep 2011 13:22:51 +0000 (15:22 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 12 Sep 2011 13:22:51 +0000 (15:22 +0200)
The position pointer is dereferenced before the check in the
for() in the list_for_each_safe macro.

Note that struct list_head should not contain NULL pointers. See
INIT_LIST_HEAD() macro.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/cache.c
libblkid/src/devname.c

index feec6ddfceb8b66dedfe542f84a94a630a7e9dfe..6ef22a103e1e2e49d30a22138db4c51ea01fe49a 100644 (file)
@@ -217,8 +217,6 @@ 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 (!p)
-                       break;
                if (stat(dev->bid_name, &st) < 0) {
                        DBG(DEBUG_CACHE,
                            printf("freeing %s\n", dev->bid_name));
index e1fc2c84995caf1bb6afab3b27fd4d43c3b48b57..f824a1795c18612afde946d19751677187a54628 100644 (file)
@@ -91,10 +91,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
                 * it.
                 */
                list_for_each_safe(p, pnext, &cache->bic_devs) {
-                       blkid_dev dev2;
-                       if (!p)
-                               break;
-                       dev2 = list_entry(p, struct blkid_struct_dev, bid_devs);
+                       blkid_dev dev2 = list_entry(p, struct blkid_struct_dev, bid_devs);
                        if (dev2->bid_flags & BLKID_BID_FL_VERIFIED)
                                continue;
                        if (!dev->bid_type || !dev2->bid_type ||