lkml.org 
[lkml]   [2008]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC v5][PATCH 2/8] General infrastructure for checkpoint restart
From
Date
On Sat, 2008-09-13 at 19:06 -0400, Oren Laadan wrote:
>
> +int cr_read_obj_type(struct cr_ctx *ctx, void *buf, int n, int type)
> +{
> + struct cr_hdr h;
> + int ret;
> +
> + ret = cr_read_obj(ctx, &h, buf, n);
> + if (!ret) {
> + if (h.type == type)
> + ret = h.parent;
> + else
> + ret = -EINVAL;
> + }
> + return ret;
> +}

This one has been bugging me a bit. This adds one net line of code and
I think it's much easier to read:

{
struct cr_hdr h;
int ret;

ret = cr_read_obj(ctx, &h, buf, n);
if (ret)
return ret;

ret = -EINVAL;
if (h.type == type)
ret = h.parent;

return ret;
}

-- Dave



\
 
 \ /
  Last update: 2008-09-15 19:57    [W:0.286 / U:0.200 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site