Patchwork sparc64: refactor code in viohs.c

login
register
mail settings
Submitter Sam Ravnborg
Date Jan. 6, 2009, 8:17 p.m.
Message ID <20090106201742.GA17714@uranus.ravnborg.org>
Download mbox | patch
Permalink /patch/16843/
State Accepted
Delegated to: David Miller
Headers show

Comments

Sam Ravnborg - Jan. 6, 2009, 8:17 p.m.
The sparc64 allmodconfig build broke due to enabling of the
branch_tracer that does some very clever things with
all if conditions. This caused my gcc 3.4.5 to be so confused that
it emitted a warning:

arch/sparc/kernel/viohs.c: In function `vio_control_pkt_engine':
arch/sparc/kernel/viohs.c:335: warning: 'nver' might be used uninitialized in this function

And with -Werror this broke the build.

Refactor code so it:
1) becomes more readable
2) no longer emit a warning with the branch_tracer enabled

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 6, 2009, 8:46 p.m.
From: Sam Ravnborg <sam@ravnborg.org>
Date: Tue, 6 Jan 2009 21:17:42 +0100

> The sparc64 allmodconfig build broke due to enabling of the
> branch_tracer that does some very clever things with
> all if conditions. This caused my gcc 3.4.5 to be so confused that
> it emitted a warning:
> 
> arch/sparc/kernel/viohs.c: In function `vio_control_pkt_engine':
> arch/sparc/kernel/viohs.c:335: warning: 'nver' might be used uninitialized in this function
> 
> And with -Werror this broke the build.
> 
> Refactor code so it:
> 1) becomes more readable
> 2) no longer emit a warning with the branch_tracer enabled
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/sparc/kernel/viohs.c b/arch/sparc/kernel/viohs.c
index 708fa17..aa6ac70 100644
--- a/arch/sparc/kernel/viohs.c
+++ b/arch/sparc/kernel/viohs.c
@@ -337,8 +337,10 @@  static int process_ver_nack(struct vio_driver_state *vio,
 	viodbg(HS, "GOT VERSION NACK maj[%u] min[%u] devclass[%u]\n",
 	       pkt->major, pkt->minor, pkt->dev_class);
 
-	if ((pkt->major == 0 && pkt->minor == 0) ||
-	    !(nver = find_by_major(vio, pkt->major)))
+	if (pkt->major == 0 && pkt->minor == 0)
+		return handshake_failure(vio);
+	nver = find_by_major(vio, pkt->major);
+	if (!nver)
 		return handshake_failure(vio);
 
 	if (send_version(vio, nver->major, nver->minor) < 0)