[Cbe-oss-dev] [PATCH] return only valid data in ibox_info and mbox_info
Arnd Bergmann
arnd at arndb.de
Tue Dec 18 13:17:27 EST 2007
On Tuesday 18 December 2007, Jeremy Kerr wrote:
> > @@ -1779,13 +1779,15 @@ static ssize_t __spufs_mbox_info_read(struct spu_context *ctx, {
> > u32 mbox_stat;
> > u32 data;
> > + u32 size = 0;
> >
> > mbox_stat = ctx->csa.prob.mb_stat_R;
> > if (mbox_stat & 0x0000ff) {
> > + size = sizeof data;
> > data = ctx->csa.prob.pu_mb_R;
> > }
> >
> > - return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
> > + return simple_read_from_buffer(buf, len, pos, &data, size);
> > }
>
> how about just returning 0 if (!(mbox_stat & 0x0000ff)) ?
I guess that would be equivalent, but I don't see an improvement over this code.
The function would then either violate the single-return-statement rule or
grow by another few lines. Also, this version is more consistent with the
existing __spufs_wbox_info_read function.
If you still prefer with a conditional return, I'll do a new patch.
Arnd <><
More information about the cbe-oss-dev
mailing list