Commit 2c99d295 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] dm: list_for_each_entry audit

From: Joe Thornber <thornber@redhat.com>

Audit for list_for_each_*entry*
parent ba657cf7
...@@ -88,30 +88,24 @@ static unsigned int hash_str(const char *str) ...@@ -88,30 +88,24 @@ static unsigned int hash_str(const char *str)
*---------------------------------------------------------------*/ *---------------------------------------------------------------*/
static struct hash_cell *__get_name_cell(const char *str) static struct hash_cell *__get_name_cell(const char *str)
{ {
struct list_head *tmp;
struct hash_cell *hc; struct hash_cell *hc;
unsigned int h = hash_str(str); unsigned int h = hash_str(str);
list_for_each (tmp, _name_buckets + h) { list_for_each_entry (hc, _name_buckets + h, name_list)
hc = list_entry(tmp, struct hash_cell, name_list);
if (!strcmp(hc->name, str)) if (!strcmp(hc->name, str))
return hc; return hc;
}
return NULL; return NULL;
} }
static struct hash_cell *__get_uuid_cell(const char *str) static struct hash_cell *__get_uuid_cell(const char *str)
{ {
struct list_head *tmp;
struct hash_cell *hc; struct hash_cell *hc;
unsigned int h = hash_str(str); unsigned int h = hash_str(str);
list_for_each (tmp, _uuid_buckets + h) { list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
hc = list_entry(tmp, struct hash_cell, uuid_list);
if (!strcmp(hc->uuid, str)) if (!strcmp(hc->uuid, str))
return hc; return hc;
}
return NULL; return NULL;
} }
...@@ -935,6 +929,7 @@ static void retrieve_deps(struct dm_table *table, ...@@ -935,6 +929,7 @@ static void retrieve_deps(struct dm_table *table,
unsigned int count = 0; unsigned int count = 0;
struct list_head *tmp; struct list_head *tmp;
size_t len, needed; size_t len, needed;
struct dm_dev *dd;
struct dm_target_deps *deps; struct dm_target_deps *deps;
deps = get_result_buffer(param, param_size, &len); deps = get_result_buffer(param, param_size, &len);
...@@ -942,7 +937,7 @@ static void retrieve_deps(struct dm_table *table, ...@@ -942,7 +937,7 @@ static void retrieve_deps(struct dm_table *table,
/* /*
* Count the devices. * Count the devices.
*/ */
list_for_each(tmp, dm_table_get_devices(table)) list_for_each (tmp, dm_table_get_devices(table))
count++; count++;
/* /*
...@@ -959,10 +954,8 @@ static void retrieve_deps(struct dm_table *table, ...@@ -959,10 +954,8 @@ static void retrieve_deps(struct dm_table *table,
*/ */
deps->count = count; deps->count = count;
count = 0; count = 0;
list_for_each(tmp, dm_table_get_devices(table)) { list_for_each_entry (dd, dm_table_get_devices(table), list)
struct dm_dev *dd = list_entry(tmp, struct dm_dev, list);
deps->dev[count++] = huge_encode_dev(dd->bdev->bd_dev); deps->dev[count++] = huge_encode_dev(dd->bdev->bd_dev);
}
param->data_size = param->data_start + needed; param->data_size = param->data_start + needed;
} }
......
...@@ -329,13 +329,11 @@ static int lookup_device(const char *path, dev_t *dev) ...@@ -329,13 +329,11 @@ static int lookup_device(const char *path, dev_t *dev)
*/ */
static struct dm_dev *find_device(struct list_head *l, dev_t dev) static struct dm_dev *find_device(struct list_head *l, dev_t dev)
{ {
struct list_head *tmp; struct dm_dev *dd;
list_for_each(tmp, l) { list_for_each_entry (dd, l, list)
struct dm_dev *dd = list_entry(tmp, struct dm_dev, list);
if (dd->bdev->bd_dev == dev) if (dd->bdev->bd_dev == dev)
return dd; return dd;
}
return NULL; return NULL;
} }
......
...@@ -25,15 +25,11 @@ static DECLARE_RWSEM(_lock); ...@@ -25,15 +25,11 @@ static DECLARE_RWSEM(_lock);
static inline struct tt_internal *__find_target_type(const char *name) static inline struct tt_internal *__find_target_type(const char *name)
{ {
struct list_head *tih;
struct tt_internal *ti; struct tt_internal *ti;
list_for_each(tih, &_targets) { list_for_each_entry (ti, &_targets, list)
ti = list_entry(tih, struct tt_internal, list);
if (!strcmp(name, ti->tt.name)) if (!strcmp(name, ti->tt.name))
return ti; return ti;
}
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment