Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1562205 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-01-18 23:00 +0100 |
| Last post | 2017-01-19 01:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 1/5] um: port: Move an assignment for the variable "fd" in port_wait() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 23:00 +0100
Re: [PATCH 1/5] um: port: Move an assignment for the variable "fd" in port_wait() Jeff Dike <jdike@addtoit.com> - 2017-01-19 01:30 +0100
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-01-18 23:00 +0100 |
| Subject | [PATCH 1/5] um: port: Move an assignment for the variable "fd" in port_wait() |
| Message-ID | <t16qS-15L-27@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 21:40:29 +0100
A local variable was set to an error code in one case before a concrete
error situation was detected. Thus move the corresponding assignment into
an if branch to indicate a software failure there.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
arch/um/drivers/port_kern.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index 40ca5cc275e9..b2bbda21c5f3 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -230,10 +230,10 @@ int port_wait(void *data)
atomic_inc(&port->wait_count);
while (1) {
- fd = -ERESTARTSYS;
- if (wait_for_completion_interruptible(&port->done))
+ if (wait_for_completion_interruptible(&port->done)) {
+ fd = -ERESTARTSYS;
goto out;
-
+ }
spin_lock(&port->lock);
conn = list_entry(port->connections.next, struct connection,
--
2.11.0
[toc] | [next] | [standalone]
| From | Jeff Dike <jdike@addtoit.com> |
|---|---|
| Date | 2017-01-19 01:30 +0100 |
| Subject | Re: [PATCH 1/5] um: port: Move an assignment for the variable "fd" in port_wait() |
| Message-ID | <t18M1-2Gh-9@gated-at.bofh.it> |
| In reply to | #1562205 |
On Wed, Jan 18, 2017 at 10:56:17PM +0100, SF Markus Elfring wrote:
> diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
> index 40ca5cc275e9..b2bbda21c5f3 100644
> --- a/arch/um/drivers/port_kern.c
> +++ b/arch/um/drivers/port_kern.c
> @@ -230,10 +230,10 @@ int port_wait(void *data)
>
> atomic_inc(&port->wait_count);
> while (1) {
> - fd = -ERESTARTSYS;
> - if (wait_for_completion_interruptible(&port->done))
> + if (wait_for_completion_interruptible(&port->done)) {
> + fd = -ERESTARTSYS;
> goto out;
> -
> + }
> spin_lock(&port->lock);
>
> conn = list_entry(port->connections.next, struct connection,
> --
> 2.11.0
>
The current code is pretty standard kernel coding style. The inline
fd = -ERESTARTSYS;
is likely free, or close to it, and I believe that having anything
besides a goto inside the if could make it significantly more
expensive.
Jeff
--
Jeff Dike
AddToIt
978-254-0789 (o)
978-394-8986 (c)
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web