From 0f2659142215f42a0f3fa94bf7da655d7275b630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Fran=C3=A7ois?= Date: Wed, 14 Aug 2013 00:03:59 +0200 Subject: [PATCH] Align coding style. * lib/subordinateio.c: Avoid implicit conversion of pointers and integers to booleans. * lib/subordinateio.c: Added brackets. --- ChangeLog | 3 +++ lib/subordinateio.c | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b87be1f..73f74824 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ * lib/subordinateio.c: Avoid dead branches. * lib/subordinateio.c: Add schematics with ranges to help reviews. + * lib/subordinateio.c: Avoid implicit conversion of pointers and + integers to booleans. + * lib/subordinateio.c: Added brackets. 2013-08-13 Nicolas François diff --git a/lib/subordinateio.c b/lib/subordinateio.c index 7811eb85..5a9f4743 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -279,35 +279,40 @@ static int add_range(struct commonio_db *db, return commonio_append(db, &range); } -static int remove_range(struct commonio_db *db, - const char *owner, unsigned long start, unsigned long count) +static int remove_range (struct commonio_db *db, + const char *owner, + unsigned long start, unsigned long count) { struct commonio_entry *ent; unsigned long end; - if (count == 0) + if (count == 0) { return 1; + } end = start + count - 1; - for (ent = db->head; ent; ent = ent->next) { + for (ent = db->head; NULL != ent; ent = ent->next) { struct subordinate_range *range = ent->eptr; unsigned long first; unsigned long last; /* Skip unparsed entries */ - if (!range) + if (NULL == range) { continue; + } first = range->start; last = first + range->count - 1; /* Skip entries with a different owner */ - if (0 != strcmp(range->owner, owner)) + if (0 != strcmp (range->owner, owner)) { continue; + } /* Skip entries outside of the range to remove */ - if ((end < first) || (start > last)) + if ((end < first) || (start > last)) { continue; + } if (start <= first) { if (end >= last) { @@ -345,7 +350,7 @@ static int remove_range(struct commonio_db *db, tail.start = end + 1; tail.count = (last - tail.start) + 1; - if (commonio_append(db, &tail) == 0) { + if (commonio_append (db, &tail) == 0) { return 0; }