libblkid: remove unnecessary position check from list_for_each_safe loops

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>
This commit is contained in:
Karel Zak 2011-09-12 15:22:51 +02:00
parent b94fecf587
commit b29a641219
2 changed files with 1 additions and 6 deletions

View 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));

View 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 ||