lkml.org 
[lkml]   [2009]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] sparc: make proces_ver_nack a bit more readable

On Mon, 5 Jan 2009, Steven Rostedt wrote:

>
> Impact: clean up
>
> The code in process_ver_nack is a little obfuscated. This change
> makes it a bit more readable by humans. It removes the complex
> if statement and replaces it with a cleaner flow of control.

Note, I do not have a sparc compiler at my disposal, so I was not
able to compile (or boot) test this change.

Here's the original code:

static int process_ver_nack(struct ldc_channel *lp, struct ldc_version
*vp)
{
struct ldc_version *vap;
if ((vp->major == 0 && vp->minor == 0) ||
!(vap = find_by_major(vp->major))) {
return ldc_abort(lp);
} else {
struct ldc_packet *p;
unsigned long new_tail;
p = handshake_compose_ctrl(lp, LDC_INFO, LDC_VERS,
vap, sizeof(*vap),
&new_tail);
if (p)
return send_tx_packet(lp, p, new_tail);
else
return ldc_abort(lp);
}
}

And the new code:

static int process_ver_nack(struct ldc_channel *lp, struct ldc_version
*vp)
{
struct ldc_version *vap;
struct ldc_packet *p;
unsigned long new_tail;
if (vp->major == 0 && vp->minor == 0)
return ldc_abort(lp);
vap = find_by_major(vp->major);
if (!vap)
return ldc_abort(lp);
p = handshake_compose_ctrl(lp, LDC_INFO, LDC_VERS,
vap, sizeof(*vap),
&new_tail);
if (!p)
return ldc_abort(lp);
return send_tx_packet(lp, p, new_tail);
}
This should be binary the same. But as I said, I do not have a sparc
compiler to test.

Thanks,

-- Steve


\
 
 \ /
  Last update: 2009-01-05 20:49    [W:0.355 / U:0.104 seconds]
©2003-2014 Jasper Spaans. Advertise on this site