From 803b7af70660332ce001c55fb9bc9e8511985421 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 3 Jun 2013 08:38:07 +0200 Subject: [PATCH] cleanup: code update and typo fix Use the same style of loop for all filter functions. Fix type compsoite -> Composite. --- lib/filters/filter-composite.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/filters/filter-composite.c b/lib/filters/filter-composite.c index 1229460f2..c2b103d9c 100644 --- a/lib/filters/filter-composite.c +++ b/lib/filters/filter-composite.c @@ -20,13 +20,11 @@ static int _and_p(struct dev_filter *f, struct device *dev) { - struct dev_filter **filters = (struct dev_filter **) f->private; + struct dev_filter **filters; - while (*filters) { + for (filters = (struct dev_filter **) f->private; *filters; ++filters) if (!(*filters)->passes_filter(*filters, dev)) - return 0; - filters++; - } + return_0; log_debug_devs("Using %s", dev_name(dev)); @@ -35,15 +33,13 @@ static int _and_p(struct dev_filter *f, struct device *dev) static void _composite_destroy(struct dev_filter *f) { - struct dev_filter **filters = (struct dev_filter **) f->private; + struct dev_filter **filters; if (f->use_count) log_error(INTERNAL_ERROR "Destroying composite filter while in use %u times.", f->use_count); - while (*filters) { + for (filters = (struct dev_filter **) f->private; *filters; ++filters) (*filters)->destroy(*filters); - filters++; - } dm_free(f->private); dm_free(f); @@ -65,7 +61,7 @@ static void _wipe(struct dev_filter *f) { struct dev_filter **filters; - for (filters = (struct dev_filter **) f->private; *filters; filters++) + for (filters = (struct dev_filter **) f->private; *filters; ++filters) if ((*filters)->wipe) (*filters)->wipe(*filters); } @@ -78,7 +74,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters) return_NULL; if (!(filters_copy = dm_malloc(sizeof(*filters) * (n + 1)))) { - log_error("composite filters allocation failed"); + log_error("Composite filters allocation failed."); return NULL; } @@ -86,7 +82,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters) filters_copy[n] = NULL; if (!(cft = dm_zalloc(sizeof(*cft)))) { - log_error("compsoite filters allocation failed"); + log_error("Composite filters allocation failed."); dm_free(filters_copy); return NULL; }