[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5212E4F2.5010001@asianux.com>
Date: Tue, 20 Aug 2013 11:39:30 +0800
From: Chen Gang <gang.chen@...anux.com>
To: Ingo Molnar <mingo@...nel.org>,
"a.p.zijlstra@...llo.nl" <a.p.zijlstra@...llo.nl>,
Mel Gorman <mgorman@...e.de>, riel@...hat.com
CC: Andrew Morton <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/2] kernel/sysctl.c: simplify code for C code readers
In related functions, they have already had tag 'free', so use 'goto'
instead of 'break' to keep one (not multiple) style in each function.
Also remove useless checking 'err' code or move it to related 'if' code
block.
Signed-off-by: Chen Gang <gang.chen@...anux.com>
---
kernel/sysctl.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ee00986..c05e2cd 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1958,27 +1958,28 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
proc_wspace_sep,
sizeof(proc_wspace_sep), NULL);
if (err)
- break;
+ goto free;
if (conv(&neg, &lval, i, 1, data)) {
err = -EINVAL;
- break;
+ goto free;
}
} else {
if (conv(&neg, &lval, i, 0, data)) {
err = -EINVAL;
- break;
+ goto free;
}
- if (!first)
+ if (!first) {
err = proc_put_char(&buffer, &left, '\t');
- if (err)
- break;
+ if (err)
+ goto free;
+ }
err = proc_put_long(&buffer, &left, lval, neg);
if (err)
- break;
+ goto free;
}
}
- if (!write && !first && left && !err)
+ if (!write && !first && left)
err = proc_put_char(&buffer, &left, '\n');
if (write && !err && left)
left -= proc_skip_spaces(&kbuf);
@@ -2206,7 +2207,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
proc_wspace_sep,
sizeof(proc_wspace_sep), NULL);
if (err)
- break;
+ goto free;
if (neg)
continue;
if ((min && val < *min) || (max && val > *max))
@@ -2221,11 +2222,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
}
err = proc_put_long(&buffer, &left, val, false);
if (err)
- break;
+ goto free;
}
}
- if (!write && !first && left && !err)
+ if (!write && !first && left)
err = proc_put_char(&buffer, &left, '\n');
if (write && !err)
left -= proc_skip_spaces(&kbuf);
@@ -2515,7 +2516,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
return -ENOMEM;
}
proc_skip_char(&kbuf, &left, '\n');
- while (!err && left) {
+ while (left) {
unsigned long val_a, val_b;
bool neg;
--
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists